How do I create bullets?

  • hello to all

    In my game, i have a sprite who is moving from left to right with the keyboard touch left-right from the directional pad (platform game)

    HOW to tell to my game, when i push "space" and moving to right the sprite shoot to the right side, if im moving to the left and push "space" i need also the same but for the left.

    thanks

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hey there, check out this tutorial about spawning bullets: "Game Development w/ Construct 2 Tutorial - 8 - Shooting Bullets" by TheNewBoston on YouTube.

    The bullet will go in the direction the sprite is facing, so if the sprite doesn't flip when you change directions, you'll have to keep track of which way the sprite is facing based on the last movement input, and flip the bullet direction manually.

  • ah thanks a lot

  • in my case i dont use at all the mouse but just the keyboard, also my sprite move only from left to right 2 directions only, so i dont know how to solve that :s

  • That's okay. How about this:

    Say your sprite starts facing to the right:

    When you press left, your sprite flips 180 to face left. When you press right, your sprite flips 180 to face right again.

    When a bullet object gets spawned from your sprite (your sprite will do "spawn another object"), it will automatically be facing the same direction as your sprite.

    Don't worry about the mouse controls in the video, just focus on how he spawns the bullet. You can use the same thing in your game when you press the spacebar.

  • If the sprite goes to the right, the Bullet behavior (applied to the bullet shot) angle of movement should be 0. If going to the left, the angle of movement should be 180.

  • thanks for your help guys

  • ok its done, but it fires too much bullets

  • ok solved, now i just need to tell to the ennemies to keep a little distance between them

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)