0 Favourites

How do I destroy a background by Index ?

  • If the condition is something like

    backgroundabc(1).x > 400 => "destroy backgroundabc"

    destroys all backgroundabc instances

    but i would like to destroy just (1) ... is there a possibility to get the index in destroy commands ?

    same goes for similar operations, like set position - i dont find a way to specify the index number

  • You dont pick the Sprite. You have to pick. Always.

    System > Pick all > backgroundabc

    System > Pick nth instance > backgroundabc ... 1

    Sprite > Compare X > 400

    Why pick all ? I wrote it there for the logic.

    Index, or the expression Sprite.IID, or 'nth' in the condition, or sprite(n).Expression ...... , all stand for the index in the picklist. Always does.

    If it is a root event, you dont need to explicitly use 'pick all', you can assume that they are all picked (like in in your case, when you dont explicitly pick em, you delete them all)

    This will not work as you intend. (to illustrate IID)

    Sprite > Compare X > 400 (picks all sprites with x > 400)

    System > Pick nth instance > Sprite ... 1 (pick the second sprite in that pick list, but that picklist is not containing all sprites anymore, just does with X > 400)

    Not sure though why you need IID.

    Sprite > Compare X > 400

    _____ destroy

    Should just do fine.

  • Thank you - it works - but i dont like the syntax

    now i got

    {Event} Pick TiledBackground instance 3 -> {Action} Destroy Tiledbackground

    which destroys just instance 3 - which is what i wanted - but from a syntax perspective i think it would be more fitting if it was ->

    {Event} Pick TiledBackground instance 3 -> {Action} Destroy Tiledbackground instance 3

  • Plz read https://www.scirra.com/manual/75/how-events-work

    The syntax perspective is pick, pick, pick pick & pick, run actions on picklist.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Ok, I understand - pick, pick, pick -

  • It' still bad syntax

    {Event} Pick TiledBackground instance 3 -> {Action} Destroy Tiledbackground instance 3 - would be correct

    if i enter

    {Event} Pick TiledBackground instance 3 -> {Action} Destroy Something_Else

    something_else is destroyed - although it has nothing to do with the TiledBackground instance 3

    ---

    and yeah, i know - pick, pick, pick

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