Spawn laser in Basic Shoot Em Up

inatnatinatnat Member Posts: 2
edited November -1 in Working with GS (Mac)
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?

Comments

  • expired_012expired_012 Member Posts: 1,802
    Try this:

    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,
  • firemaplegamesfiremaplegames Member Posts: 3,211
    And also set game.shoot back to 0 right before the spawn behavior in the rule.
  • expired_012expired_012 Member Posts: 1,802
    Yea, missed that one. Sorry about that mr. Perfect!!! ;)
  • YozefYozef Member Posts: 1
    Thanks guys :)
    Spawn Actor is the trick
Sign In or Register to comment.