Create 1 object on top of another chosen object.

0 favourites
  • 6 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • EDIT: Realized I did not describe that properly. I want to select all the blocks of the same color that are also next to the block clicked on.

    I have a grid of 99 sprites. I am attempting to select all the blocks of the same color. When you click on a block it changes that blocks opacity to 50%. Then I spawn a sprite that is cross shaped, if any of the neighboring sprites are on the same animation frame, it changes their opacity to 50% (there are probably other ways of doing this but...). I only want it to create one cross, but it keeps creating crosses forever, they are all on top of each other, but they are there. How do I make it only do it once? I fear someone is going to tell me to read "How events work", but I must not be understanding something there.

    <img src="" border="0" />

  • Another detail - event 5 - I want it to be recursive (if that's the right word)

    It finds all the adjacent sprites that are the same color, makes them opacity 50, and then checks all the new opacity 50 sprites for sprites on the same animation frame, and then checks those for matching neighbors, until there are no more.

    It does that fine the way it is, but it just keeps creating the neighbor-checking sprite forever....

  • Right now, every tick that gamestateflag = 1 a sprite is created.

    system: trigger once while true, might be what you want..

  • So, I made a condition that changed the GameState Flag to 2 when the Number of sprites with opacity 50 was less than the number of "neighbor checkers". Destroyed the neighbor checker in the layout at the start of the layout, and when the click was negated.

  • Instead of creating a cross on every sprite, you could just use one cross and move it around. Here's an example that does that. It uses a boolean "checked" to track which sprites have been checked already.

    pickColors.capx (r100)

    Here's another approach that does all the checking in one tick using a while loop and an array to store a queue of sprites to be checked.

    pickColors2.capx (r100)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for those examples. This is now solved in a couple of ways!

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