Sprite Movement

0 favourites
  • 5 posts
From the Asset Store
Run and Jump in 3 Dimensions! Take your platformer to the next level!
  • Can someone give me a hint on how to do the following:

    1) I have three sprites, that will start moving from the center of the screen to the left on the start of the layout. They have the 4 directions (left, right, up, down) and are bound to layout.

    Q: 1) How do I detect that they hit the left boundry?

       2) Move all of them at that point down by by y pixels?

       3) Change the direction for all three of the sprites to right?

       

    Also, how could I do an effect like in space invaders when the shield gets hit by a bullet, it gets partially destroyed? Do I have to make multiple PNG and test for the collision, and display different frame, or is there an easier way that does this dynamically?

    Thanks for your help/suggestions.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 1) assuming the pivot is in the center of the sprite

    foreach Sprite
    Sprite.X >= LayoutWidth-Sprite.Width/2
        -> Sprite: set touchBoundary to true
        -> Sprite: set yStart to Sprite.Y

    yStart is an instance variable

           

    2)

    Global variable yPixels = 100
    Sprite: Y position is lower than Sprite.yStart+yPixels
    Sprite: is touchBoundary
        -> Sprite: set Y to Sprite.Y+50*dt

    will move the sprite by 100px down at 50px/sec

    3) how do you move them to left in the first place?

    I think you can achieve this effect with the canvas, by pasting your shield on start of frame, and then pasting a destination out blowing sprite on top of it to erase them.

  • 1. Not sure what you mean, but I think you would just compare the x value. Like spite.x< n.

    2. Depending on your movement style you would just reference sprite.y + n amount.

    3. There are 2 way I can think of, but until families, or containers are implemented it can be a bit tricky. Right now for the first method you could add a bunch of sprites to be the barrier, and have them always set position offset from the main sprite. To do that you would need to use index's like barrier(0)set position to mainsprite(0).x+n,mainsprite(0).y+n, and barrier(1)set position to mainsprite(0).x+n+n,mainsprite(0).y+n+n. For the second, which is easier, you can make a bunch of frames, and have that non moving animation set position to the main sprite. Then on collision you just change the barrier's frame to the next.

    Also Ninja Yann

  • I had System On start of layout do a Simulate 8Direction pressing Left for the object, but that did not seem to work. So I set another System event for Every tick to do the same.

  • Thanks for the responses and suggestions. Will try it over the weekend.

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