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 / moving and animating a sprite at the same time

Author
Message
Deion
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United States
Posted: 5th Sep 2011 02:39
i am using this to load and setup and animate a sprite a woman walking




now to make it animate i use

PlaySprite (2, 7, 1, 1, 9)

and to move the sprite around i use

SetSpritePosition (2, newX#, newY# )

however i noticed that i cant move the sprite around and have the walking animation at the same time. it will move the sprite to desitination then play the animation

even if using

PlaySprite (2, 7, 1, 1, 9)
SetSpritePosition (2, newX#, newY# )


or

SetSpritePosition (2, newX#, newY# )
PlaySprite (2, 7, 1, 1, 9)


is there a way to do it asynch so it can run both commands at once?

Cheers,
Deion G.
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 5th Sep 2011 03:59 Edited at: 5th Sep 2011 04:01
Without seeing your code, I'll hazzard a guess...

You have the PlaySprite() command inside the loop where the movement commands are.

PlaySprite() only needs to be called once, outside the loop. It runs by itself, until you tell it to stop.

It will play the same starting frame every time it is called. Then, when you stop calling it, the animation will play the rest of the frames.

So, in answer to your question, PlaySprite is already asynchronous.

Deion
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United States
Posted: 5th Sep 2011 04:49
here is the code i am using



just as a side not though, if i comment out the
SetSpritePosition (spriteID, x, y)

it takes like 4 seconds til the animation truely starts animating. the file isnt to big i have it attached.

i guess what i dont understand is that the main game loop will always be running, from direct x past, its fairly easy to start animating a sprite then move it all at the same time, by doing much what i already have above.

thanks for the help


p.s. is there a equivelent to vb's doevents function that will force the animation to run while moving by using the above code?

Cheers,
Deion G.

Attachments

Login to view attachments
Deion
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United States
Posted: 5th Sep 2011 04:56
opps never mind i realize what you meant, i put a flag showing it was curently animating so it would no longer call the PlaySprite command and now they both are in sync.

thanks

Cheers,
Deion G.

Login to post a reply

Server time is: 2024-11-24 00:20:45
Your offset time is: 2024-11-24 00:20:45