Missile Question - Can a missile shoot towards where you touched the screen?
samdelgado
Member Posts: 10
Hey everyone,
I am new around here and have just been fooling around with gamesalad to see what it can do. I have a basic idea of game I might try making, but I can't figure out how to create something. Essentially I want a game like the Space Rocks demo, but you move the ship with a virtual joystick with your left thumb and you shoot the missiles by tapping on the screen where you want it to go. So I still want the missiles to leave from the actor, but I want them to go to wherever my finger touched the screen. Is this possible? Thanks for your help in advance.
I am new around here and have just been fooling around with gamesalad to see what it can do. I have a basic idea of game I might try making, but I can't figure out how to create something. Essentially I want a game like the Space Rocks demo, but you move the ship with a virtual joystick with your left thumb and you shoot the missiles by tapping on the screen where you want it to go. So I still want the missiles to leave from the actor, but I want them to go to wherever my finger touched the screen. Is this possible? Thanks for your help in advance.
Comments
I got the email and of course it was a stupid as forgetting to actually drag the actor onto the screen. My game isn't much like space rocks one I was just using that to try to get the functionality down. Thanks a lot for helping me out!
To get it to actually shoot, you would need to use that expression in a CHANGE VELOCITY or MOVE behavior.
put the vectorToangle part in the direction
So this wrapped in change velocity did work ... as stated by barkbark00.
vectorToAngle( game.touch x - self.Position.X , game.touch y - self.Position.Y )
Note to myself * Re-read things ... several times!
Basically i want my actor to rotate and fire the missile where i touch. e.g. if he is straight and i touch in front of him he just fires the missile, if i touch diagonally right i want him to rotate diagonally left a bit so that he is again parallel to where he is shooting.
I tried creating a rule that said if touch.x and touch.y is greater than self.position x and y then rotate to x but once i have the 4 scenarios in place and the main actor is moving quite a bit it doesnt detect it to well. Anyone got any ideas on this? Can it be done with some math?
not that i can solve your problem, but specifying the whole action should help someone help you better
imagine the actor is in the centre of the screen
If you touch top right, he would rotate anti-clockwise 45 degrees and shoot straight to the top right corner
If you touch bottom right he would need to rotate 45 degrees clockwise and shoot straight to bottom right.
What i would like is it to override on new touch. i.e. If you're firing top left and then hit top right it switches straight away rather than wait for a sequence to complete.
Same rules apply for the left hand side.
Now i guess it would need to be rotate to angle and not just rotate as if you hit top left 1st and then top right you would end up in your original position as opposed to being rotated to the correct position to fire straight.
from the Wiki:
http://gamesalad.com/wiki/interface_reference:expression_editor
vectorToAngle
Usage: vectorToAngle(x,y)
Find the angle relative to the origin, (0,0), given an X and Y coordinate. You can include an offset,(x',y'), to find an angle relative to the offset.
e.g. vectorToAngle(x-x',y-y')