tap location and shoot towards location
tollhousestudio
Member Posts: 166
is this possible? I'm trying to make it so that if you tap the screen a bullet will fire in the direction of where I tapped.
Possible? if so, could someone help out.
Thanks in advance.
Possible? if so, could someone help out.
Thanks in advance.
Comments
Create a rule that says when mouse button is clicked (or touch is pressed)
change game.targetX to touch.X
change game.targetY to touch.Y
change shoot to true
then in your bullet place a move towards behavior. For x use game.targetX and y use game.targetY
In your shooter create a rule that says:
when game.shoot is true
spawn bullet.
change attribute game.shoot to false (so it doesn't just keep shooting)
I'm at work and not on a mac so I can't test this. Seems like it should work. good luck!
http://gamesalad.com/game/play/26389
is that what you mean?
I created a few global attributes - shoot, x, y
it was pretty easy, what I did was create a bullet, and define added two attributes to the bullet itself - X & Y.
I added two change attribute rules -
change self.X to game.X
change self.Y to game.Y
and a timer
after 1 second
destroy
I also created an accelerate toward rule on the bullet towards self.X and self.Y
then on your actor that shoots the bullet I had a rule
when game.Shoot = 1
spawn bullet
and then to actually capture and shoot, I created an actor called Capture that was the size of the background. On that I created a rule:
when actor receives touch
change attribute game.Shoot = 1
change attribute game.X to device.X (device - touch 1 - y)
change attribute game.Y to device.y (device - touch 1 - y)
something like that anyways, this allows you to shoot multiple bullets in a row, each going to it's own direction. My way will have the bullets continue off the screen, but if you do Move in stead of Accelerate, it will stop wherever you clicked.
I'm pretty sure Tshirtbooth or someone made a quick tutorial, it should be in the games section
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
Any other suggestions? is this the right way of doing it or is there some missing info?