How do I delete only specific text object

  • hi

    i build a game that place random squares instances across the layout and in every square there is txtQuestion = text object

    now every time there is 2 square instances that overlap each other i want to destroy them the square and the txt

    i tried do:

    event 1 = when 2 square overlap = instance variable square and txt = overlap /true

    event 2 = if squre and txt = instance variable overlap true

    action = delete square , delete txt

    the 2 square are been deleted but txt delete all the txt over the layout

    what can i do

    or what is a better way to prevent object respawn on another object

    and sorry about my English.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I’d put your text objects and boxes in a container. I’d also use a function to pick your squares to be deleted by UID (this will help with picking). When the square is deleted its corresponding text object should also be deleted since they would be in a container.

  • thank you

    it work by using container.

    what i did is: select box and than make container and added text.

    event 1 ) on start of layout, txt set position by object = box

    event 2 ) every 2 sec, create object = box on floor random x/y + make boolean "new" = true

    sub event ) if new = true , wait 1.5 sec set boolean new = false.

    event 3) if box overlap box + box new = true, delete box

    by doing that i mange delete only the new box+txt and prevent new box be created on top of other boxes.

    but i dint understand how to do what you suggest with "UID"

    "function to pick your squares to be deleted by UID"

    can you pls show me how its done.

  • Hey! Glad that helped! Absolutely. Here is a capx with comments to explain how to pick by UID with functions. I also demonstrate the use of functions to create new objects without overlapping. I've also added a challenge in the capx using and array to pick UIDs to be deleted, as that may be helpful in the future.

    https://www.dropbox.com/s/jymq0k2kiy0wo ... .capx?dl=0

  • thank you very much i learn a lot .

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