How do I create a trigger based on Compare X?

0 favourites
  • 6 posts
From the Asset Store
Game Triggers is as versatile as a Swiss army knife, and will be a great resource for any type of game you're creating.
  • On start of layout a sprite(bird) is created that has simulated 8 direction movement based on an instance list. From start the bird simulates movement downwards. At the same time another sprite(airspace) is created and is every tick placed beneath the bird sprite. This airspace sprite only serves the purpose of ensuring the bird doesn't reach the solid ground closer than 16 pixels. On collision with solid, the airspace sprite gets destroyed, and on that trigger, the bird sprite simulates moving right instead.

    Now here is my issue.

    I would like this sprite to change the simulated movement upwards when it reaches the X cord of BBoxRight of a third sprite(nest) that's already existing in the level. However I'm not entirely sure how to go about this.. I've tried to experiment with the compare X function, however there's surely something I'm missing in my execution. I guess what I've done is creating an event that compares X cord of bird sprite with BBoxRight x cord of nest sprite, but nothing triggers the bird to simulate movement upwards.

    All chime ins are appreciated.

  • Could be one of two problems, you're comparing an 'exact' X which might never be true, so try greater or less than. You are still simulating the bird to move down so they conflict, need to disable one movement and enable the other.

  • Also, you don't need that airspace sprite, you can use "Is Overlapping at offset" condition. Try something like this:

    On every tick
     Bird X>Nest.BBoxLeft 
    	: Bird simulate moving Up
    
     Else
     Bird Overlapping Ground at offset X=16 
    	: Bird simulate moving Right
    
     Else
    	: Bird simulate moving Down
    
  • Thank you both for the assistance!

    I will keep your advice in mind when comparing cords. Another thing. How do I disable the current simulated movement before replacing it with another direction? Do I just use Stop 8 Direction?

    dop2000 I've decided to use your suggestion. It seems to work out really well. There's only one minor thing with this execution. After the bird changes movement towards right, it moves for about 3 times its tile size before stopping for almost a second and starts spinning the animation violently before proceeding as normal. In the end taking the last turn and simulates moving up. I've set the 8Direction Set Angle to 90 intervals.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I want to believe that the random spinning animation has something to do with the bird animation finishes going through its four frames and repeats. Even if I set the birds 8 Direction Set Angle properties to 'No', and apply a 'Set angle to 90 degrees' and '..0 degrees' function on the corresponding Every Tick and Else events, the animation still seem to stop and spin before looping through the frames.

  • Another headsup. It seems like the spinning animation issue have solved itself somehow. Not sure how but all is joy now.

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