Jump to content

Search the Community

Showing results for tags 'oncomplete'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 12 results

  1. Hi, I'm having a problem (it looks like a bug) with phaser.signal detecting when a video has ended when using changeSource function. I'm using phaser 2.4.8 (but it also happened with 2.4.6). To reproduce the issue, please change both videos and the image button with some media you have. Once you run the demo, check your developer console each time button is pressed. The first time the video is stopped, it says "Played 1 times" The second time it says "Played 2 times" AND "Played 3 times" The third time it says "Played 4 times", "Played 5 times" AND "Played 6 times" and so on... It's like it is reporting when each video has stopped, not just the video that has just been "source changed". Here's the code: window.played = 0; var game = new Phaser.Game(1280, 720, Phaser.AUTO, 'gameCanvas', { preload: preload, create: create}); function preload() { game.load.video('Blank', 'vids/blank.mp4'); game.load.image('btn','gfx/btn_conoce.png'); } function create() { button = game.add.button(100, 400, 'btn', btnClick); video = game.add.video('Blank'); video.addToWorld(0, 0, 0, 0, 0, 0); videoOnStop = new Phaser.Signal(); video.onComplete = videoOnStop; game.world.bringToTop(button); videoOnStop.add(function() { played++; console.log("Video Stopped: Played " + played + " times"); }); } function btnClick() { video.changeSource('vids/anothervideo.mp4'); video.play(false); } Greets!
  2. I have been trying to set up a chain of tweens for hours, without results. This is what I want to accomplish: Target is a group, located above the world Tween 1 Arrive: group comes down into x:48, y:96, then Tween 2 Swing: group starts moving back and forth (yoyo) between initial x value and given x value. Tween 3 Creep: In Tween2's onLoop.add a tween is called to move the group in y axis When stage ends, the group must go back its initial position, and its children sprites recreated, so in a restart function I stop Swing tween and to its onComplete add: Tween 4 Go back: group goes back to y, a large negative number which hides it again, on its onComplete I add a call to the function which will create Arrive, Swing and Creep tweens. The problem I'm facing is that in restart, the Swing tween doesn't seem to be stopping even though I call .stop() upon it and everything seems to be executing out of order. Here's the code: Tweens for aliens arriving, swinging and inching downward: //Aliens arrive! this.aliens.x = 96; this.movDat.ay = -(this.world.height/2); this.aliens.y = this.movDat.ay; this.movDat.aliensSwing = new Phaser.Tween(this.aliens,this,this.tweens); this.movDat.aliensSwing.to({x:256},2000,Phaser.Easing.Linear.None,false,0,-1,true); this.movDat.aliensSwing.onLoop.add(function(){ this.movDat.ay+=10; this.add.tween(this.aliens).to({y:this.movDat.ay},2000,Phaser.Easing.Linear.None,true,0); console.log('swung!! moving to y:'+this.movDat.ay); }, this); this.movDat.aliensArrive = new Phaser.Tween(this.aliens,this,this.tweens); this.movDat.aliensArrive.to({x:96, y:48},1000,Phaser.Easing.Cubic.Out,false); this.movDat.aliensArrive.onComplete.addOnce(function(){ console.log('arrived!! swinging from x:'+this.aliens.x+' y:'+this.aliens.y); this.movDat.ay=48; this.movDat.aliensSwing.start(); },this); this.movDat.aliensArrive.start(); Code in level restart function to tween aliens offscreen, and call the fn with code above: console.log('aliens going back...'); this.movDat.aliensSwing.stop(true); this.movDat.aliensSwing.onComplete.addOnce(function(){ this.movDat.aliensGoBack = new Phaser.Tween(this.aliens,this,this.tweens); this.movDat.aliensGoBack.to({y:-400},1000,Phaser.Easing.Linear.None,false);console.log('no more swinging...'+this.movDat.aliensSwing.isRunning); this.movDat.aliensGoBack.onComplete.addOnce(function(){console.log('aliens gone back'); this.aliens.removeAll(); this.createAliens();},this); this.movDat.aliensGoBack.start(); },this); I've had to already shelve another game because I haven't been able to understand the tween system. Any help is appreciated.
  3. I see that there is an onComplete method on the Animations but I can't figure out how to use it. I want to run a function everytime an animation has been completed. Can someone explain how this can be done, my way of doing it now has me watching for the isFinished property to equal true, but this seems like the wrong way to do it.
  4. icp

    2.4.2 loadTexture

    I'm using a tween that changes the texture of a Sprite when onComplete method gets called. Sometimes it fails to change the texture via this.sprite.loadTexture('myTexture'); . Everything works fine with Phaser 2.3 .
  5. Hi, I was looking at the chained tweens example and I tryed to add an onCompete event at the end of the tween but it's look like the event is dispatched after the end of the first tween. var tween = this.game.add.tween(this.phaser).to({ alpha: 1 }, 1000, Phaser.Easing.Sinusoidal.InOut, true).to({ alpha: 0 }, 1000, Phaser.Easing.Sinusoidal.InOut, false, 1000).onComplete.add(this.onAnimationDone, this);I found this solution on the forum wich is not ellegant, but at least functional: var tween = this.game.add.tween(this.phaser).to({ alpha: 1 }, 1000, Phaser.Easing.Sinusoidal.InOut).to({ alpha: 0 }, 1000, Phaser.Easing.Sinusoidal.InOut, false, 1000).start(); tween._lastChild.onComplete.add(this.onAnimationDone, this);I would like to know if it is the expected behavior or if there is a better way to do that ? Thank you.
  6. Anybody ever have this problem before?, In this code: while (killedSprites.length > 0) { var sprite = killedSprites.shift(); var tween = game.add.tween(sprite); tween.to({ alpha: 0 }, 100, Phaser.Easing.Linear.None); tween.onComplete.add(function () { sprite.destroy(); }); tween.start();}Why is it that when killedSprite has more than 1 sprites, only the first sprite gets detroyed even if the tweens are all run and complete.
  7. Hello ! I have a quite simple problem (Phaser 2.0.2). On a custom Sprite with an animation, I call sprite.Destroy() when the animation is complete but then it throws me "TypeError: this.currentAnim is null" (line 37562). Here's my code: SpecialFX = function(_x, _y, _spriteName) { Phaser.Sprite.call(this, game, _x, _y, _spriteName); this.animIdle = this.animations.add('idle', [0, 1, 2, 3, 4], 10, false); this.animIdle.onComplete.add(this.animationStopped, this); this.animations.play('idle'); game.add.existing(this);};SpecialFX.prototype = Object.create(Phaser.Sprite.prototype);SpecialFX.prototype.constructor = SpecialFX;SpecialFX.prototype.animationStopped = function() { this.destroy();};It looks like the AnimationManager attached to my sprite is not destroyed and still try to update. Thank you in advance.
  8. Hi, I would like to know what's the best way to trigger my function with chained tweens. The following code doesn't really work. The function which contains the "alert" is triggered when the first tween completes. var jumpTween = game.add.tween(playState.player); jumpTween.to({ y: 70 }, 200); ju empTween.to({ y: 150}, 400); jumpTween.onComplete.add(function(){console.log("CIAO");}, this); <--- This is triggered when y=70. jumpTween.start(); Is there any elegant solution which doesn't involves combined tweens? (http://examples.phaser.io/_site/view_full.html?d=tweens&f=combined+tweens.js&t=combined%20tweens) Cheers, Antonio
  9. Here are my animations baddie.animations.add('fly',[0,1],5,true);baddie.animations.add('hit',[2,0,2],10,false);baddie.animations.play('fly');When the baddie is hit: baddie.animations.play('hit');It plays the hit animation once, then stays on the last frame. Is there a way I can get it to fire an event, or process a function after the animation is done? I can see there is a killOnComplete option, but no onComplete function option. The only real way I can see this working is having a timer or counter, then going back to the fly animation, but that's a bit sloppy and could get annoying with multiple baddies.
  10. Hi PandaJS, I'm trying to add an onComplete() function to a tween. This is what I have so far: var tween = new game.Tween(sprite) .to({x:100, y:100}, 1000) .easing(game.Tween.Easing.Back.Out);tween.start();Do you know how I add an onComplete function? Thanks a lot!
  11. Hello guys, Im not sure if it is a pixi-bug or my own code but maybe you can evaluate this better than me I created a MovieClip with an onComplete callback to remove itself. Works fine, but as soon as there are more MovieClips, pixi throws an error: Uncaught TypeError: Cannot call method 'updateTransform' of undefined pixi.js:3126 PIXI.Stage.updateTransform pixi.js:3126 PIXI.WebGLRenderer.render pixi.js:4460 animate (index):24 Looks like that the MovieClip is removed and pixi still wants to call updateTransform. The easy way is to put tons of if(indexOf(mc) != -1)'s to the compiled pixi code but that cant be the correct way to do it You can get the lines here: http://kuboid.net/explosion.zip or here: http://kuboid.net/explosion.rar Thank you in advance
  12. With this code: tempBrick.animations.add('idle', ['brick_' + bID + '_1.png'], 10, false, false); tempBrick.animations.add('brick_die', [ 'brick_' + bID + '_1.png', 'brick_' + bID + '_2.png', 'brick_' + bID + '_3.png', 'brick_' + bID + '_4.png' ], 10, false, false); tempBrick.animations.add('brick_popin', [ 'brick_' + bID + '_4.png', 'brick_' + bID + '_3.png', 'brick_' + bID + '_2.png', 'brick_' + bID + '_1.png' ], 10, false, false);And then later I want to play and add custom callback when animation is played: I saw that there is: onComplete() and also a onAnimationComplete event but for that I need the animation instance... So what i thought is to get the instance from the sprite.animations ... something like sprite.animations.get("brick_die"); But the animationMnager doesn't have such a thing... there is a /*** @property {object} _anims - An internal object that stores all of the Animation instances.* @private*/ this._anims = {}; But I don't think it's supposed to be used... Also I could make a instance once I'm adding them to the sprite.animation like: var IdleBrickAnimation = tempBrick.animations.add('idle', ['brick_' + bID + '_1.png'], 10, false, false); and then: IdleBrickAnimation.onComplete(myCallBack); But since I do it in the different places and methods I expected that there is a way to get a animation by name and then play it and add a callback specifically for this play.
×
×
  • Create New...