Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Question about animating sprite

Author
Message
Abiz
11
Years of Service
User Offline
Joined: 14th Nov 2012
Location: Amsterdam
Posted: 17th Dec 2012 23:37
I create a sprite with a number of frames and use SetSpriteAnimation. All works fine.

When I want to change all frames from that sprite (using a new picture), I now delete the sprite, so in fact creating a new sprite. Disadvantage is that I have to set positioning etc. again.

Is there a better/other way to do this, without having to delete the original sprite? Something like UpdateSpriteImage()
Or is this the normal procedure?
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 18th Dec 2012 00:10
There's a SetSpriteImage command.

Abiz
11
Years of Service
User Offline
Joined: 14th Nov 2012
Location: Amsterdam
Posted: 18th Dec 2012 00:29
I presume you mean this webpage:
.../documentation/Reference/Sprite/SetSpriteImage.htm
Which gives an error. The page is not there.

I tried it with this syntax:
SetSpriteImage( sID, image_ID) but that doesn't work.

It looks like only the first frame is altered. The rest of the animation remains the same.
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 18th Dec 2012 00:45
Quote: "I presume you mean this webpage:
.../documentation/Reference/Sprite/SetSpriteImage.htm
Which gives an error. The page is not there.
"

Works on this end.

Quote: "It looks like only the first frame is altered. The rest of the animation remains the same."

You might need to set up the animation again. Could we see your code?

Abiz
11
Years of Service
User Offline
Joined: 14th Nov 2012
Location: Amsterdam
Posted: 18th Dec 2012 01:12
Of course. It's just a test program.
Both pictures contain 10 frames of 40x40.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 18th Dec 2012 03:50
It's entirely possible that things are happening so fast that you aren't seeing them.

You aren't limiting your frame sync at all.

Also, before you change the image, you need to stop the animation.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 18th Dec 2012 04:49 Edited at: 18th Dec 2012 04:49
Slowing it down is a good idea, change the variable fps to something like 1 or 2.

This works (you'll have change the images loaded back to yours):


DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 18th Dec 2012 06:58
I've just knocked this little snippet up. I think from looking it is probably similar to what has been suggested. It may help you suss it out though.


Abiz
11
Years of Service
User Offline
Joined: 14th Nov 2012
Location: Amsterdam
Posted: 19th Dec 2012 01:32
Thanks for all help and suggestions. I got it working.
Main missing instruction was: setspriteanimation() after I set the new sprite image.

PS: Regarding my remark about the missing webpage: That's only a Mozilla problem. IE has no problem finding it.

Login to post a reply

Server time is: 2024-05-06 11:50:32
Your offset time is: 2024-05-06 11:50:32