what should be a simple task...

0 favourites
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • hey guys, ok i know this should be a simple task and few members have tried to explain it to me but being the impatient type that i am i just cant seem to grasp it.

    ok so in my game the player can create objects in runtime, so far they can create infinate number of the same object (for example, a "ball")

    now what i want is so when the player creates ball number 2 (which is the same object as the 1st) ball number 1 gets destroyed.

    i know it sounds simple and it probably is, however ive really hit a rock here and cant figure it out. <img src="smileys/smiley7.gif" border="0" align="middle" />

  • Question is, do you really need to destroy it?

    I ask this, as destroying an object and creating one in the same event can get complicated.

    Have you thought about simply setting the objects opacity to 0, and then setting it back to 100 after a wait?

  • well i think its my only option, once they create one ball and its gets used, they will create another. that 1st ball will never really get used again so i thought destroying is the only option.

    i guess i could have 2 objects and as you said make 1 invisible while the other shows, and simply keep switching between them..

    what ive gathered so far is i can do the destroying technuiqe by giving the ball a UID, so the 1st ball would have a UID of 0 and second ball would be 1, then something like

    if UID is higher than 1 - delete ball with instance of 1 - change value of UID of ball 2 to 1

    thats even if that would work, if so i cant seem to write the events for it lol

  • Feels like I'm missing something here? Wouldn't it work to just

    add two actions to your event in the following order:

    • Destroy "ball"
    • Spawn "ball"

    This will get rid of any instances of "ball" before creating a new one.

  • andreas, sadly no, i tried that at 1st but didnt work, this just destroys the current object before its even created, basicly not creating an object at all

  • Yes, you can do that, but both instances will be in the sol.

    Think of it like a goldfish bowl. You kill one, and then add one before taking the other one out.

  • Add a destroy ball thanet a wait 0.1 seconds then spawn a new one..

  • i tried that also, with no avail.

    i think i didnt explain it correctly, at least made a mistake when i said ball lol.

    mediafire.com

    there is the file, as you can see you are able to use left mouse button to "draw" lines on the screen, i want it so when i create a second line, the 1st gets destroyed.

  • What you're describing is a group of instances. For that I would suggest using a variable like:

    Sprite.variable"drawn"=1, destroy sprite

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • hmm ive tried methods like that however it always destroys both objects. hmm maybe im just making a slight mistake somewhere..

  • Maybe you don't need more than one at all. If one is being destroyed the instant one is being created, why not MOVE the first one to where the second one WOULD be created? It's essentially the same thing, isn't it? If you post your capx I'd be glad to try and get it working for you. <img src="smileys/smiley1.gif" border="0" align="middle" />

  • oooh now thats an idea i havent tried... and could work <img src="smileys/smiley1.gif" border="0" align="middle" />

    heres the cap.x dude

    mediafire.com

    thankyou!

  • p.s its the bar object which i only want 1 of at a time, just incase i didnt make it clear <img src="smileys/smiley4.gif" border="0" align="middle" />

  • The sprites default value should be set to not destroy it. You change the value when you want to destroy it.

    It's more about how you are choosing when it should draw at this point.

  • ahh i think i get it a little better now, so my mistake is by trying to destroy the 1st object, instead chnage the value of the 1st and then destroy..

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