how to change the sprite frame, to point to the mouse

This forum is currently in read-only mode.
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • does anybody know how to set the frame number to the angle of the mouse coordinates from a sprite object... sorry if im not making any sense, i've been up all night and now its over 12pm.

    What i want to do, is have my player character point his gun towards the mouse regardless of what direction he is moving.

    some unfinished sprites

    <img src="http://img.photobucket.com/albums/v403/puppeli/Player_1b.png">

    its easy to do in game maker "point_direction(x,y,mouse_x,mouse_y) /45", but i've run into some different problems there that would be so easy to do in Construct

  • I think what you're looking for is set the animation frame to: angle(.x, .y, mousex, mousey)/45

    You might need to round it, though, I'm not sure. If so, try this: round(angle(.x, .y, mousex, mousey)/45)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • If the animation frames start with right then go clockwise this formula will work:

    round(angle(.x, .y, mousex, mousey)/45)%8+1

    You can also setup animation angles so that when you point an object to a point construct will automatically select the closest angle.

    Here is two ways to do it:

    http://dl.dropbox.com/u/5426011/examples5/lookat.cap

    made in cc1.2

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)