Changing animation in real time

36 views
Skip to first unread message

FreshManGaming

unread,
Nov 20, 2017, 7:59:03 PM11/20/17
to cocos2d discuss
Hi all,

I'm trying to change an animated GIF in real time to another animated GIF, e.g. from an idle state to a running state depending on a key-press. 

So far I have managed to load in the idle animated GIF but I am struggling to replace the idle GIF to the running GIF,

I have looked into using Pyglet's Animation class however whenever I use from_image_sequence the program just crashes. 

Are there any ways to change a sprite represented by a GIF in real time with another GIF temporarily depending on a key-press?

Thank you.

claudio canepa

unread,
Nov 20, 2017, 10:22:19 PM11/20/17
to cocos2d discuss
Yes. The sprite.image attribute controls which image will be shown.

So the issue would be how to access each picture into the .GIF

I modified the cocos' s example test/test_animation.py first to explore the GIF and then to change the picture at each SPACE key release.

Attached as test_animation_2.py, put in the test/ directory so the gif can be found.





--
You received this message because you are subscribed to the Google Groups "cocos2d discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cocos-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to cocos-...@googlegroups.com.
Visit this group at https://groups.google.com/group/cocos-discuss.
For more options, visit https://groups.google.com/d/optout.

test_animation_2.py

claudio canepa

unread,
Nov 20, 2017, 10:43:45 PM11/20/17
to cocos2d discuss
Oh, sorry, I misread as "want to manually set which picture in the gif will be shown when pressing a key" while you want multiple gifs, and jump to one to the other.
One possibility it is to join all the gifs in only one gif and proceed as before.

Else, for sepparate gifs you should look at the pyglet.sprite.Sprite code, in particular to the __init__ and _animate methods and see how to manipulate the sprite animation state to switch between gifs.
  

FreshManGaming

unread,
Nov 21, 2017, 4:55:39 AM11/21/17
to cocos2d discuss
Thank you very much exactly what I was looking for.


On Tuesday, November 21, 2017 at 3:43:45 AM UTC, Claudio Canepa wrote:
Oh, sorry, I misread as "want to manually set which picture in the gif will be shown when pressing a key" while you want multiple gifs, and jump to one to the other.
One possibility it is to join all the gifs in only one gif and proceed as before.

Else, for sepparate gifs you should look at the pyglet.sprite.Sprite code, in particular to the __init__ and _animate methods and see how to manipulate the sprite animation state to switch between gifs.
  
On Tue, Nov 21, 2017 at 12:22 AM, claudio canepa <ccan...@gmail.com> wrote:
Yes. The sprite.image attribute controls which image will be shown.

So the issue would be how to access each picture into the .GIF

I modified the cocos' s example test/test_animation.py first to explore the GIF and then to change the picture at each SPACE key release.

Attached as test_animation_2.py, put in the test/ directory so the gif can be found.




On Mon, Nov 20, 2017 at 6:52 PM, FreshManGaming <freshman...@gmail.com> wrote:
Hi all,

I'm trying to change an animated GIF in real time to another animated GIF, e.g. from an idle state to a running state depending on a key-press. 

So far I have managed to load in the idle animated GIF but I am struggling to replace the idle GIF to the running GIF,

I have looked into using Pyglet's Animation class however whenever I use from_image_sequence the program just crashes. 

Are there any ways to change a sprite represented by a GIF in real time with another GIF temporarily depending on a key-press?

Thank you.

--
You received this message because you are subscribed to the Google Groups "cocos2d discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cocos-discus...@googlegroups.com.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages