I'm creating a turret defense game. The player can shoot a bullet but it's only straight way. I want to let the player to set the angle of the cannon manually, so the cannon can shoot the bullet at many different angle.
In the "spawn bullet" event, you need to set the bullet's angle of motion based on the angle of the cannon. Or depending on the orientation of the cannon sprit you might need to offset by 90 degrees.
and I don't want it using a mouse or other PC things, because this game is for android, so any idea for touch mode?
You could do something like:
Touch: is in touch -> Cannon: set angle to angle(self.x,self.y,touch.x,touch.y)
oh okay
The cannon is as I expected, but the angle of the bullet still wrong. Did I did something wrong?
You want to set the Bullet's "Angle Of Motion", not just its angle - assuming you have added the Bullet behavior?
Develop games in your browser. Powerful, performant & highly capable.
it changes but the bullet still shoot the wrong direction
I don't want to sound mean but I think you need to spend some time with the tutorials and examples.
Check out the Ghost Shooter example. You can see that the bullet inherits its direction of movement from the player object, because the player object spawned it.
You should also check out the Beginner's Guide and Platformer tutorial, if you haven't already done them.
Finally it works! Thanks!