Jump to content

How to remove animation just after playing one time (loop == false)?


krystianjjj
 Share

Recommended Posts

Hello,

 

I have started using panda js which is awesome. I got some questions to it.

 

1. Is it possible to remove animation just after playing it e.g. onComplete function does not work, at least I wasn' able to handle it?

2. Is it posible to set framerate for game in config?

3. If I run some animation onComplete of another animation there is a one blink of new animation at position x=0, y=0 (but the position of new animation is defined somwhere else).

 

Thank you for answering those questions

Link to comment
Share on other sites

Yeah, panda is awesome!

 

BTW, about your questions:

 

1) you can create your animation with:

var yourObject = new game.Animation(                'images/obj-1.png',                'images/obj-2.png',                'images/obj-3.png'                );yourObject.animationSpeed = 0.1;yourObject.anchor.set(0.5, 0.5);yourObject.play();yourObject.loop=false;game.scene.stage.addChild(yourObject);

This code play your animation only one time, and the last frame will be your final texture (in the example case, obj-3.png will be the static sprite).

 

With :

yourObject2 = new game.Animation(              'images/FINAL-Sprite.png'              );      yourObject.onComplete(function(){       yourObject.textures = yourObject2.textures;});yourObject.play();

You'll change the sprite of your object to a new one (in this case FINAL-Sprite.png)

 

2) I don't know if you can set a FPS limitation, sorry ^^

 

3) maybe you want to use .textures function, see answer #1

Link to comment
Share on other sites

Thank you for an answer. With the second scenario I get an error in line 126 (Uncaught TypeError: object is not a function)

        yourObject = new game.Animation(                'pyt-short_000.png',	        'pyt-short_001.png',		'pyt-short_002.png'        );	yourObject.position.set(0, 0);        yourObject.anchor.set(0.5, 0.5);        yourObject.animationSpeed = 0.3;	yourObject.play();	yourObject.loop = false;        game.scene.addObject(yourObject);	yourObject2 = new game.Animation(		'LFruits_sym1_00019.png'        );	yourObject.onComplete(function(){	       yourObject.textures = yourObject2.textures;	});	yourObject.play();

Anyway I got another question. Is it possible to wait for animation complete until the next code will be executed, or even execute some code with some delay regarding current animation. Lets say I have 3 fileds and I want to make an animation on three of them. Fitstly I would like to run animation on 1st one then in the middle of current animation run animation on 3rd field and then in the middle of second animation run animation on 2nd field. In all cases animation is the same. Thanks in advance.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...