Targeting a specific layer

Get help using Construct 2

Post » Mon Feb 18, 2013 10:29 pm

Hello

I have some collectibles in my game... when the user picks one up, I display it in a score box. At the end of the game I want to kill all the collectibles that weren't picked up... the problem is, when I destroy them, it destroys the ones in the score box as well.

Since I can move the objects I collect to another layer, I can have the ones I collect on layer 1, and the ones I've picked up on layer 2. My question is, can I tell the game to destroy the collectibles only on layer 1?

Or - is there a more elegant way of doing this?

I can't post the file since it's a project for work

Thanks
B
5
Posts: 17
Reputation: 459

Post » Mon Feb 18, 2013 10:39 pm

There is a condition "Is on layer" - on the bottom of the Add event window, under Z Order section.

Are your collectibles instances of one sprite?

If so you could create boolean for them and set it to true after picking them up.
Then on the layout end you can do:
collectibles.boolean = false - > destroy

it will only destroy the ones that not have been picked up.
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Mon Feb 18, 2013 10:46 pm

I probably should have explained it better... my apologies...

I am aware I can set booleans and check for layers, but I can't seem to do it after a condition

The condition I currently have is:

If > onGameEnd = 0 > perform these actions

It seems I can't add further logic in those actions, or in other words, conditionals within conditionals
B
5
Posts: 17
Reputation: 459

Post » Mon Feb 18, 2013 10:56 pm

Do You mean something like that ?



If not, could you upload an image of that part of Your code, if You don't want to upload capx file?
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Mon Feb 18, 2013 11:21 pm



So basically I'm not sure how to destroy those on specific conditions when I already have conditions in place. Do I need to add additional conditions to each of the original 'or' conditions?

Thanks
B
5
Posts: 17
Reputation: 459

Post » Mon Feb 18, 2013 11:34 pm

You can add sub-event for this condition

+expenseCount => totalCount
+or
+coinsCount => totalCount
     +sprite is on layer = 1 -> destroy - or whatever you want
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Mon Feb 18, 2013 11:52 pm

Like this? It still doesn't destroy them, even though you can see they're created in layer 1

Phill2013-02-18 23:53:56
B
5
Posts: 17
Reputation: 459

Post » Tue Feb 19, 2013 12:19 am

Seems to work when I call a function I just created to do the same check, weird
B
5
Posts: 17
Reputation: 459


Return to How do I....?

Who is online

Users browsing this forum: djcrazypants, marekmk and 7 guests