How do I configure order of this event sheet?

Get help using Construct 2

Post » Thu Oct 23, 2014 11:01 pm

Hi there.

I have an issue with order of events.

I have this:

Image

So basically on block destroyed event runs -> it spawns new block at new location.
Then once spawned all blocks in certain range changes variable to +1.

All works fine besides the fact that this dont work on newly created objects.
Since multiple objects are destroyed at once - I want this to run every destroyed block.
Instead it seems it runs just once and newly created objects are not picked by the event sheet.

I am really puzzled, am I missing something?
B
10
S
1
Posts: 56
Reputation: 654

Post » Fri Oct 24, 2014 2:45 am

Newly created objects can't be picked until the next top level event. So the object you just spawned is not picked in event 18 by the "pick all" condition. The new object is picked right after creation though, so you could do something like this:
Code: Select all
16|Block : on detroyed            | System: set blockY2 to Block.y1
  |System: move=0                 | System: set blockX2 to Block.x1
  |                               | System: set Move to 1
  +-------------------------------+
   17|System : for each block     | Spawner: Spawn Block on layer 2 (image point 0)
     |Spawner: Position=block.x1  | Block  : Set x1 to Spawner.Position
     |System : move=1             |
     +----------------------------+
      18|System: Pick all block   | Block : Add 1 to y1
        |Block : y1<blockY2       |
        |Block : x1<blockX2       |
        +-------------------------+
      19|Block : y1<blockY2       | Block : Add 1 to y1
        |Block : x1<blockX2       | System: set Move to 0
        +-------------------------+

You can simplify it further. The "move" variable events can be removed since it starts and ends as 0. Also the "for each" can be removed since "on destroyed" is run once for each destroyed object.
Code: Select all
16|Block : on detroyed            | System: set blockY2 to Block.y1
  |                               | System: set blockX2 to Block.x1
  +-------------------------------+
   17|Spawner: Position=block.x1  | Spawner: Spawn Block on layer 2 (image point 0)
     |                            | Block  : Set x1 to Spawner.Position
     +----------------------------+
      18|System: Pick all block   | Block : Add 1 to y1
        |Block : y1<blockY2       |
        |Block : x1<blockX2       |
        +-------------------------+
      19|Block : y1<blockY2       | Block : Add 1 to y1
        |Block : x1<blockX2       |
        +-------------------------+


One final observation, since you create a block for each destroyed block couldn't you instead just move the block instead of destroying it?
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Post » Fri Oct 24, 2014 2:52 am

I had no idea you couldn't pick objects that where just created when you wanted to pick them in a subevent of the creating event =O

This clarifies some things.

@R0J0hound you've thought me so much over the years =P
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Fri Oct 24, 2014 3:18 am

@Sargas
It is picked by default in sub-events, hence event 19 is working with the new object. It's the "pick all" that won't be able to pick it since the new objects aren't in the object list yet.

This topic explains the reason:
viewtopic.php?f=147&t=116098&p=837060&hilit=picked#p837060
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Post » Fri Oct 24, 2014 7:12 pm

R0J0hound - thanks! I actually completely missed the idea of moving object instead of creating new one. I think when you sit to long on simple problem you cant see bigger picture that clear :/

This solved all my issues nicely. Thanks a lot! Much appreciated :)
B
10
S
1
Posts: 56
Reputation: 654


Return to How do I....?

Who is online

Users browsing this forum: blue visionary and 5 guests