Sign in to follow this  
xronn

Sprite follow another sprite

Recommended Posts

Hi,

 

Using Phaser 1.1.3 I saw in the examples the following snippet of code -

game.physics.moveToPointer(sprite, 400);

Can I use this same method to make one sprite follow another sprite?

E.g;

game.physics.moveToSprite(sprite, sprite2, 400);

Share this post


Link to post
Share on other sites

I am not sure about this, but i think that this is what you are looking for, post something if this does not work.

Btw, you have to put this in a update method.

game.physics.moveToObject(displayObject, objectToFollow, speed, maxTime)

Share this post


Link to post
Share on other sites

Hey thanks, that works but the max time parameter seems to be different, I think the max time is the speed and I don't see any effect on what the 3 parameter does :S 

Is there a max time parameter that would be very useful.

Share this post


Link to post
Share on other sites

i am also implementing the same functionality in my game......the problem arises at the point where the sprite following the other sprite is not touching the ground and its not stopping where it should when it reaches close to the sprite being followed and also when the path finishes.

any help in this regard would be highly appreciated.

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.