How do I change/destroy a specific object?

0 favourites
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hello,

    To present the context i'am making a puzzle game with a mechanic who uses colors.

    To help people who suffers from colorblindless and other visuals troubles to play comfortably, i add symbol to let people know which color is actually present on the screen. The symbol indicate which color is the sprite.

    For the moment I hesitate between two options but none work.

    *Everytime the player touch a sprite to change the color a symbol is create in a specific point on this sprite.

    The trouble here is that if the players touch again the same sprite it creates another symbol.

    How did i destroy the first symbole created?

    *The symbol is already create with different frames. Each time the players touch the sprites, the symbol changes frame so it looks like another symbol.

    The probleme is, i have on screen different sprites with each one a symbol on it.

    When i touch one sprite, the symbol of all the sprites changes.

    May I ask you what should I do to correct it? And what is my best option in term of optimisation and everything?

    Thanks for your help

  • This is all about picking and relating the symbol to the object. In simplest way you can say 'on touch object' pick symbol that is overlapping object, destroy it. And for the second part, pick in the same way and change it. There are other ways to relate symbol to object but this is a basic way.

  • Thanks for your answear,

    Sorry i need you again.

    How I would detect if a sprite have already been create on the point?

  • Again you can say if a symbol is overlapping it then it is true. You can do this by other methods though, on touching the object you can set an instance variable to true to note that you touched it and created a symbol.

  • Sorry,

    The problem is in the way i made the game. Many sprites overlapp each other.

    So a symbol won't overlapp one sprite but all of them.

    That's why i which to use a way to detect if a symbol(sprite) had been create on a specific point.

  • You can use a Container to deal with this.

  • How you think i should use it?

    It's written:

    "If one object in a container is destroyed, every other associated object in its container is also destroyed."

    So it won't only destroy my symbol but also the sprite in relation.

  • The way I do it is to give the 2 objects instance variables, like an ID, and then they are the same number so they relate to each other. Will that work?

  • So I should create a another object symbol for every sprite.

    It will make me add around a thousand of sprite. A lot of works and not sure about the optimisation^^

  • Hi there.

    If you could provide some clearer drawing or mockup layout, if possible the project or some minor form of it, it would be maybe easier for the community to visualize a solution tailor-made for your problem.

  • No, containers do what you want. You put objects A and B in a container, and as soon as you pick one, it picks the other. In your case, it will pair the objects and they are automatically associated. Give it a try. It will take seconds.

  • Hi,

    I'm not sure I fully understand the use case, but what I can say is that if you're looking for an understanding on how picking, creating, destroying works, maybe you can watch my tuts on creating a bubble shooter

    youtu.be/Skc7JJOYSOI

    or a 3 match game

    youtu.be/9ISEJK8vtZI

    A lot of destroying, creating and picking going on there.

    Sincerely hope that helps

    Cheers

  • No, containers do what you want. You put objects A and B in a container, and as soon as you pick one, it picks the other. In your case, it will pair the objects and they are automatically associated. Give it a try. It will take seconds.

    So i will have to create an object for each sprite of my game and a container to link them.

    It's a puzzle game with around 12 sprites by level and 120 levels.

    Won't it make the game slower in term of optimization?

  • No, you said your colours map to symbols, so you add the Container to the colour sprite, and include the symbol sprite. Now they are paired.

    http://www.blackhornettechnologies.com/Construct3Stuff/Samples/container_mathie.zip

    Click the blue sprite and it turns clockwise, while the corresponding green sprite turns counter-clockwise - the picking is automatic.

    construct.net/en/make-games/manuals/construct-3/project-primitives/objects/containers

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry i explain myself badly.

    I have one sprite who changes color.

    Player choose a color and when click on sprite, it changes a local variable. And the local varible made change the color of the sprite.

    All my sprite who changes color are in one family "E"

    I will create for each another sprite symbole.

    Make a container to link them

    And hope it works :)

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