Firing left and right

This forum is currently in read-only mode.
From the Asset Store
A complete set of graphical user interface (GUI) to build 2D video games. With wood, nature, & jungle theme
  • Hi, I'm wondering how you can make the player with platform controls fire left and right and maybe up.

  • One thing you could try is setting a private variable on the player, like a string called 'direction', and have it set to 'left', 'right', and 'up' when the player is pressing those controls - up, probably only when held. Then, when the fire button is pressed, determine angle from the player based upon 'direction'. This is a non-programmer's version, though.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Could you explain that a bit more I don't really understand

  • Here, look at this:

    http://www.mediafire.com/?e9raxnx8yx1

    Look at it. LOOK AT IT AND LOVE IT AAAAHHHRRGGGG!!!

    Anyway, there are three objects here... a player, a bullet, and the barrier to keep the player from going offscreen.

    We can ignore the barrier.

    Look at the bullet. Check out it's properties. It's set to Bullet Movement. Easy enough, eh?

    Now look at the player. Double-click it. Select Image Points in the Picture Editor. Notice where the "fire" image point is set. Now go back to the layout.

    Select the player again, and look at the Animator Bar tab. Notice that there are two angles for the player, 0 degrees and 180 degrees (right and left). If you select the 180 degrees animation and double-click the frame in the Animator Bar, you will notice that the "fire" Image Point is set up here as well... but it's on the opposite side. This is because we have to compensate for the gravitational field of Jupiter during winter. Or maybe because the player is just facing the other way.

    Now look at the Event Sheet Editor. We have three simple events:

    <img src="http://xs123.xs.to/xs123/08032/shoot493.jpg">

    The first two orient the player when we press a directional key. This is based off the angles set up in the animator bar.

    The third fires a bullet. The bullet spawns at the player's image point "fire." It automatically orients itself based on the player's angle. There is no need to specifically tell it which way to go, it already knows. It's got a doctorate in physics.

    If you study this example, I'll bet you can figure out how to make your player shoot up, as well. I mean shoot in an upward direction, not take heroin. Winners never use drugs.

  • Hehe, thanks deadeye, good demo <img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /> If I had a gold star, I'd give you one.

  • Thanks that worked wonders.

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