Spawn laser in Basic Shoot Em Up
inatnat
Member Posts: 2
I would like to add a button in the screen to fire the laser instead of using the space key
My problem is how to set the X,Y position when spawning the laser which should be vary according to the ship actor
I currently is using a attribute and set to true when button is pressed, and in the ship actor, using a timer to check for the attribute and spawn when it's true.
It's seems not a good way to do it, any advise can be given?
My problem is how to set the X,Y position when spawning the laser which should be vary according to the ship actor
I currently is using a attribute and set to true when button is pressed, and in the ship actor, using a timer to check for the attribute and spawn when it's true.
It's seems not a good way to do it, any advise can be given?
Comments
First make a game integer attribute named "shoot"
Next make your shoot button and add it in your scene. In the shoot button give the rule:
When touch is pressed
Change attribute: Game.shoot to 1
otherwise
Change attribute: Game.shoot to 0
..................................................................
Now make a missile actor and give it the following behaviors:
move: 90 degrees, speed 300, relative to actor
timer- after 1 second, destroy actor
................................................................
Now go into your player actor and give it this rule:
When game.shoot is 1:
Spawn Actor (missile): Direction 0 degrees, Position= X 0, Y 32,
Spawn Actor is the trick