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 / Timed sprite movement

Author
Message
MobileCreator
12
Years of Service
User Offline
Joined: 1st Jun 2011
Location: Ottawa - Canada
Posted: 17th Oct 2011 16:54
I read the documentation about the moving the sprite based on time, and I have implemented it. But, not for my surprise, the code the way is shown in the documentation moves my sprite only every second. Is that really as it looks like?

Later I saw here in the forum someone mention the GetFrameTime which seems to do exactly what the code in the docs intend to do. Are really they equivalent.

Independent of the code used, I then tried to use floats instead of integers to move my sprite smoothly, but that make me think if I'm not wasting CPU cycles setting the same sprite position over and over. Should I check if x and y are the same before calling the function. Is it worth?

Any help is appreciated!

Thanks

----------
Paulo
http://www.mobilecreators.com
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 17th Oct 2011 17:42
Quote: "Independent of the code used, I then tried to use floats instead of integers to move my sprite smoothly, but that make me think if I'm not wasting CPU cycles setting the same sprite position over and over. Should I check if x and y are the same before calling the function. Is it worth?"

It's quicker to set the position every loop than it is to check if it needs setting and then set it (that's two operations instead of one). Setting sprite position is very quick, I wouldn't worry about it.

bjadams
AGK Backer
15
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 17th Oct 2011 19:26
Setting the position of a sprite every loop is the standard way to do it.

Login to post a reply

Server time is: 2024-03-28 18:51:31
Your offset time is: 2024-03-28 18:51:31