what should be a simple task...

Get help using Construct 2

Post » Fri Jan 20, 2012 11:21 pm

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.
B
10
S
1
Posts: 39
Reputation: 1,053

Post » Fri Jan 20, 2012 11:28 pm

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?
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Fri Jan 20, 2012 11:35 pm

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
B
10
S
1
Posts: 39
Reputation: 1,053

Post » Fri Jan 20, 2012 11:47 pm

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.
B
7
S
2
G
4
Posts: 8
Reputation: 2,673

Post » Fri Jan 20, 2012 11:50 pm

@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
B
10
S
1
Posts: 39
Reputation: 1,053

Post » Fri Jan 20, 2012 11:55 pm

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.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Fri Jan 20, 2012 11:55 pm

Add a destroy ball thanet a wait 0.1 seconds then spawn a new one..
B
29
S
12
G
7
Posts: 740
Reputation: 7,839

Post » Fri Jan 20, 2012 11:59 pm

i tried that also, with no avail.
i think i didnt explain it correctly, at least made a mistake when i said ball lol.
http://www.mediafire.com/?jplv3lzeaejipdx

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.
B
10
S
1
Posts: 39
Reputation: 1,053

Post » Sat Jan 21, 2012 12:19 am

What you're describing is a group of instances. For that I would suggest using a variable like:
Sprite.variable"drawn"=1, destroy sprite
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Sat Jan 21, 2012 12:24 am

hmm ive tried methods like that however it always destroys both objects. hmm maybe im just making a slight mistake somewhere..
B
10
S
1
Posts: 39
Reputation: 1,053

Next

Return to How do I....?

Who is online

Users browsing this forum: benajad, Braus, R0J0hound, shinkan and 24 guests