rotate to position on press - need help
mutinysoft
Member Posts: 59
hello, sorry i have a bit of a rudimentary question im making an ipad game where the character is a turret gun and wherever the player presses on the screen the turret will turn to that angle of the press and perform the shoot animation and fire the bullet in that direction.
how do i do this?
how do i do this?
Comments
Then
When mouse button is down
--Rotate to Angle vectorToAngle(self.position.x-game.mouseposition.x,self.position.y-game.mouseposition.y)
Hope that helps
Aaron
First off, like tenrdrmer said, have the turret image face the right.
Then create a rule that says when mouse button is down
--Timer every 0.000001 seconds
--Rotate to Position X = devices.mouse.position.x Y = devices.mouse.position.y
Also make it so that there is a small animation or whatever where the image changes to your firing image and a bullet actor spawns at an angle of 0 degrees relative to your turret actor and at the edge of your turret actor (so if you had a turret with a width of 100, spawn the bullet at an X of 50 relative to your turret actor).
I hope this helps.