Jump to content

Sprites with different speeds


crazzter
 Share

Recommended Posts

First of all: I'm really new to this stuff so please bare with me  :) (I'm mostly a backend guy with an urge to gain new skills)

 

How would you go about making one sprite move ten times as fast as another? I'm saying "ten times" and not "twice as fast" on purpose. Twice as fast could probably be accomplished by doing this in the animation loop: 
   sprite1.x += 1;

   sprite2.x += 2; 

 

But jumping 10px would not look very nice :-) Most of all it's about learning to do things right. Not just making it work.

 

Hope my question is not too trivial or stupid  :huh:

 

TIA!

Link to comment
Share on other sites

Don't take this as saying your question is stupid, but... think about it for a minute.

If sprite1 is moving at 1px per frame, how can sprite2 move at 10 times that speed without therefore moving at 10px per frame?

So the example you proposed for moving at double the speed is also correct for moving at 10 times the speed if simply changed to

sprite1.x += 1;sprite2.x += 10;

Whether or not moving at 10px per second looks nice depends on factors like frame rate, monitor refresh settings etc.

If you are interested in making movement look nice then I recommend reading up on animation with tweens, easing algorithms and so on.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...