Targeting a specific layer

0 favourites
  • 8 posts
From the Asset Store
Aim carefully a shoot the ball at the target to earn scores!
  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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

  • Do You mean something like that ?

    <img src="http://dl.dropbox.com/u/34375299/Construct%202/bugs%20and%20fixes/onend.JPG" border="0" />

    If not, could you upload an image of that part of Your code, if You don't want to upload capx file?

  • <img src="http://www.coflash.com/stuff/helpconstruct.png" border="0" />

    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

  • You can add sub-event for this condition

    +expenseCount => totalCount

    +or

    +coinsCount => totalCount

         +sprite is on layer = 1 -> destroy - or whatever you want

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

    <img src="http://www.coflash.com/stuff/helpconstruct2.png" border="0" />

  • Seems to work when I call a function I just created to do the same check, weird

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