sprite copying

Get help using Construct 2

Post » Mon Dec 16, 2013 8:30 am



I have a sprite that I copied...now when i destroy one sprite it destroyed the others too, whats the best way to clone/copy a sprite but make the events or conditions individual?   Not sure how to explain it, i want the events/conditions the same but only when its happening to that single sprite...
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Mon Dec 16, 2013 8:48 am

try reading:
https://www.scirra.com/manual/75/how-events-work

Basically all sprite are given a UID. So it you want to destroy the specified sprite, you have to pick the correct ones.
B
17
S
8
G
4
Posts: 93
Reputation: 3,190

Post » Mon Dec 16, 2013 4:48 pm

well im not trying to affect a specific one...i just have my sprite enemy that I made and made a copy of it...for some odd reason when i interact with one they all do the events....and not sure why...is there a certain way i need to copy so that they work on an individual bases?

B
9
S
2
Posts: 272
Reputation: 1,632

Post » Mon Dec 16, 2013 5:11 pm

Your not picking an instance in your event, so the event works for all instances of the object.

In the FAQ of this forum there are many topics about how picking works and how events work.

In this case if adding a for each condition would work, for it would check per instance if your conditions are true, but I recommend you read up on how events work and how picking works, it will save you a lot of headaches.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Dec 16, 2013 5:18 pm

is there a way to copy a sprite and not make it an instance....?

its wierd, not sure how I did it before....i have another enemy where I copied it...i have events for it when my bullet hits the enemy it destroys the enemy...and when i do that for one of them it does not affect all of them.........

just not sure what i am doing diff
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Mon Dec 16, 2013 11:23 pm

well I just do not get it...in this example I do not call any specific ID or instance... and it works just fine...the only sprite that is destroyed is the one that my bullet is colliding with.....

in the code above, the player collides with the (sprite) and a whole bunch of events happen, for some reason it happens to all of them...

how can in one situation it does not affect all sprites but in another situation is does....i did not call upon a certain sprite with a individual id.......and it seemed to work when only one sprite hit another.....i just dont get it...


B
9
S
2
Posts: 272
Reputation: 1,632

Post » Mon Dec 16, 2013 11:43 pm

Right clicking on the sprite and selecting "Copy" makes a new instance of that same sprite.

Clicking "Clone" makes a whole new sprite with the same settings as the first one. and deleteing the first one won't delete this one.

You can see it won't have the same name in the object list. it will add a number to it.

And on picking...

It looks like you might be using a variable compare to pick, and variable compare doesn't pick.
basically, if the little icon next to the event is a gear, it's not picking.Paradox2013-12-16 23:46:16
B
226
S
60
G
33
Posts: 902
Reputation: 39,989

Post » Tue Dec 17, 2013 4:30 am

"It looks like you might be using a variable compare to pick, and variable compare doesn't pick.
basically, if the little icon next to the event is a gear, it's not picking."


Hey Paradox, what is this referring to? what lines of code. I am not familiar with picking. I assume that it means the selection of an object by Id?
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Tue Dec 17, 2013 4:31 am

http://www.dwbailey.com/images/birdcopyIssue.capx
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Tue Dec 17, 2013 4:41 am

If you play that capx, you will see in level one that when you fire on the nut sacks only 1 will open , even though the others are copies. Which is what I want......so the issue that I cannot grasp is , why does the bullet not affect all of them when I collide with the first nutsack?

I mean I get why..because they have different ID's,

but why then when I collide with my bird, then i go to the struggle event and I win and the bird is destroyed, it destroys all of them instead of just the one im am interacting with.....people say its because I do not specify a certain instance....but if that were true then why does it work with the nutsacks when i do not specify a certain one there?

sorry , i just really need to understand this, its hard to move on. ha
B
9
S
2
Posts: 272
Reputation: 1,632

Next

Return to How do I....?

Who is online

Users browsing this forum: wizdigitech and 15 guests