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 / Sprite Animation logic troubles - please assist

Author
Message
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 5th Feb 2013 05:39
I've been trying to work this out all day and I'm almost there, but I'm not sure why my sprite animation is playing only after I release the mouse button...
What should happen is that the ship should bank left if you click to the left of the ship and it should bank right when you click anywhere to the right of the ship. It will roll back to 0 degrees when the mouse button is released, but I've REM'd out that procedure to try to help determine the problem area

The sprite moves left and right, no problem, but the frames don't advance until the mouse button is released.

My frames in the following code are a bit off still, but my major issue is that the sprite's animation not playing until the mouse is released.

All thoughts on how to do this or do it better are quite welcome.

A side question related to this project is: the sprite sheet is larger than 1024, is the sheet being scaled down to 1024 even though I am using frames that are 256x256?

Thanks!!



Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Feb 2013 11:40
You are constantly resetting call_play to 1 so the frame is being reset to the start frame too. You need to do a check for getPointerPressed when setting this so it only does it when the user first clicks. You might be better using setSpriteFrame manually and taking complete control of what the current frame is. Personally I find it much easier to keep a handle on things that way.


this.mess = abs(sin(times#))
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 6th Feb 2013 00:09
Thanks baxslash, I was tossing checks in everywhere. I apologize for the sloppiness. I did have this working using a GetPointerPressed() check, but I want the user to be able to swipe, so their finger may not leave the screen.
I'll just have to add that in as a condition to updating the frames too.
I do think I'll need to use SetSpriteFrame() to control the animation. I'll only rely on PlaySprite() when the mouse/touch is released.
Thanks for the help!

Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 8th Feb 2013 03:29
Thanks again, baxslash!
I fixed it all up and the ship rolls left and right like a charm.

Here's the code if anyone needs to see an example of how to animate a sprite while moving it.



Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 8th Feb 2013 10:49
Glad to help!


this.mess = abs(sin(times#))

Login to post a reply

Server time is: 2024-05-08 04:05:55
Your offset time is: 2024-05-08 04:05:55