How to change sprite position under certain circumstances?

0 favourites
  • 6 posts
From the Asset Store
Minimal Sprite Font with Stroke for Pixel Art games.
  • So I'm making this game about bluntly building a wall. Even here, there are a lot of things that put me in a choke, and I'll be greatful if you guys helped me.

    Maximum blocks you can build on a wall is 5. Once a block is broken, more is added to the maximum, so I can build blocks infinitely by breaking them. It's intended.

    Now the building zone, it's red and you can't build unless you're in collision with an invisible sprite.

    It moves up after a block is built, but the problem is, I do not know how to move it down in case a block is broken, resulting in endlessly building upwards.

    Can someone tell me how to put it on an empty block space once one is broken? .capx is included:

    drive.google.com/file/d/1O8tCBvbCKqt5KLLK8dIM5GWNf7wu0eNP/view

    Use 0 key on your numpad to throw projectiles to break the wall.

    You can also press N to give yourself money if you run out of it while testing.

    Thank you! <3

  • There are lots of ways to do this, depends what you want. I see your blocks are immovable so they won't be dropping down with any real physics. When a block is destroyed you can do the following, spawn an invisible detection object OR get the co-ordinates of the block that was just destroyed. Then do a check, any blocks where Y is less than the location of that destroyed block, move them down 20 pixels. The movement down you use set Y to self.Y+20 if they are going to teleport, or if you want to see them move down you can tween the block to self.Y+20 over time.

  • Thank you for your reply!

    get the co-ordinates of the block that was just destroyed. Then do a check, any blocks where Y is less than the location of that destroyed block

    How do I do that Construct-wise? :c

  • On your events for destroy block on hit by the projectile, you can take the Y co-ord of the block at this point and set its value to a global variable. Then you do pick by evaluate, blocks where Y is less than the global variable, moved them down by 1 space i.e. 20 pixels.

  • On your events for destroy block on hit by the projectile, you can take the Y co-ord of the block at this point and set its value to a global variable. Then you do pick by evaluate, blocks where Y is less than the global variable, moved them down by 1 space i.e. 20 pixels.

    For some reason even this confuses me as I am very new.

    I solved this by making the build zone appear where the broken block was, but I'm still confused as to how to move blocks down. You will really help me out if you added me on discord: THEleg#4962

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sent an invite, pending...

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