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 / Help Run Animation

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 13th Nov 2013 23:35 Edited at: 13th Nov 2013 23:36
Hi.
This is my code and I want create my sprite but I don't know how can make my sprite?

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 13th Nov 2013 23:43
With that, you would have to change the sprites image for each frame, like keep track of the frame number which would relate to your Player[] array, then change the image when that changes. So if the player is running, increment the frame, and if the frame is >12 then make it 7 then change the image.

But, if you keep your sprites on a single image, like a 8x8 grid - you can just set the animation then the frame for the sprite - should be easier to work with than individual images. You have to consider the other sprites you'll add as well, I don't think it would do productivity any good to use individual images, I find it's better to have a single sprite sheet per character. Also, if you have a lot of the same sprite, like an enemy character, then having a single sprite sheet means much faster rendering, as all those sprites will be drawn in the same draw call, because that goes by image. Things like item pickups as well, saving on the number of images you use can really help with mobile platforms especially.

I am the one who knocks...
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 14th Nov 2013 13:06
I'll expand upon what VanB has already said. Here's a quick example creating an animated sprite and having different 'states' so the program knows when to play an animation and when not too;



Image needed is attached.

A character is no different, you just have more 'states' then a simple explosion. Example: idle, moveleft, moveright, jump, etc. In your program you'd just check for each state and use the playsprite() command for each.

Quick example:



You can do this check for each state and then play the sprite with the correct frames. This is a quick and easy approach. There's room for expansion to create smooth transitions between frames and etc.

Only other thing, get rid of that function(). It's not benefiting your program any. Now combining all the sprite creation commands into one as a function would.

Hope this makes it more clear.

Inmortalis Nox

Attachments

Login to view attachments
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 21st Nov 2013 19:18
no, I loadImage my player Sprites to 12 array.I want show and Play this animation in another function:
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 21st Nov 2013 19:51
If you setup your run animation as a single image with frames, then there is no need for either the function or array. Honestly I have no idea why you made a function that does only one specific task only once and why you loaded the images into an array. I think your'e doing more work then necessary.

Sorry.

Trust me, it'll save you allot of headache in the long run to make your run animation into one single image and use the SetSpriteAnimation() command to load the frames.

Inmortalis Nox
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 21st Nov 2013 20:09 Edited at: 21st Nov 2013 21:23
I Fix it without use array.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 21st Nov 2013 22:21
I have a question: My Character have a several animation. for change every animation I should use CreateSprite for each?

Login to post a reply

Server time is: 2024-05-20 09:50:03
Your offset time is: 2024-05-20 09:50:03