sprite copying

0 favourites
From the Asset Store
A set of 10 pixel art animated magic effects with icons. 2 Fire, 2 Earth, 2 Wind, 2 Water, Portal, Explosion.
  • 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...

  • try reading:

    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.

  • 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?

  • 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.

  • 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

  • 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...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • "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?

  • 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

  • Like I thought..

    The nutsack event is like this:

    acornbullet on collision with nutsack - do stuff

    Both acornbullet and nutsack are referenced in the event.

    There is only one acornbullet colliding with one nutsack, so it is very clear which nutsack is meant.

  • I'm working on a tutorial about picking, because there are still many questions about it. I'm not that good at writing (and explaining), so it might take some time..

    Here's a quick look at the rough draft:

    How does picking work?

    When first starting to work with construct 2 (and even for some of us working with C2 for a longer period) it can be hard to make actions that only affect the instances of an object you'd like to affect.

    Let's start with the simplest event:

    Bullet on collision with enemy ? enemy destroy

    In this event it is clear that it is our intention to only destroy the enemy that is hit by the bullet and it works as expected.

    In my understanding Construct 2 reads this line something like this:

    Destroy each enemy instanc that is hit by a bullet.

    Without undertsanding how picking works one of the first issues arrive when trying to destroy enemies when their healthpoints are low.

    Let's have a look at these events:

    (enemy has been given an instance variable ?health? set to 2)

    Bullet on collision with enemy ? enemy subtract 1 from health

    System compare two values : enemy.health < 1 ? enemy destroy

    When testing these events with multiple enemies on screen, you will see that if you hit one enemy two times, all enemies on screen are destroyed. What is wrong here?

    Basically the first event works as intended, 1 is subtracted from the enemy health variable of that instance only, much like the enemy destroy action mentioned before C2 reads the first event something like this:

    Subtract 1 point from the health from each enemy instance that is hit by a bullet

    So the trouble must be in the second event.

    How does C2 interpret that event.

    Check if the health from any enemy is lower than one, if so destroy all enemies.

    But why?

    This is because we haven't told C2 in the event which enemy we are talking about in the action following the event. No enemy instance is referenced in the event, so the actions apply to all enemy instances.

    How to solve this?

    The simple answer is: By telling C2 what instances should be affected by the action(s)

    One way would be to make the system compare event a subevent of the collision event. We have seen that in the collision event the right enemy is picked so adding a subevent it's actions will be referencing the same instance.

    Another way would be adding a system for each enemy as a condition to the second event. That way C2 will pick an enemy, test if the condition is true, act accordingly and pick the next instance and repeat the testing, untill all enemies have been picked and tested.

    So with the for each event the instances are picked before testing the other conditions and as such the actions are related to the picked instance.

    ...

  • Hey littlestain a tutorial would be awesome, anyway you can do a video? Just explaining your thought process and all that. Right now I am watching the construct 2 class videos on youtube.

  • I have not messed with constuct 2 in a few weeks because I cannot figure out this For each issue with my enemy.

    Event lines 109-125

    dwbailey.com/images/birdInstanceIssue.capx

    Goal...When bird has line of site, it swoops down and upon collision with ground it begins a walk... when player contacts bird it brings up this Struggle meter icon and you try to win the battle by pressing Left Right, Left Right, if you when it destroys the bird, if you lose it brings up a heart...

    Issue, the code I have creates un knowing results. when i collide and win the struggle, it destroys what seems to be the original placed bird sprite in the scene , even if I collide with the 2nd bird placed in the scene....just some varies things are happening...instead of the events just happening to each bird when the player come in contact with that particular bird......now some one mentioned clarifying instant id's or something......like I would have to rewrite that code for each birds ID..sounds like more work than it should be.

  • gamejolt.com/games/platformer/squirrel-nuts/18498

    to play the game and see exactly what i mean....just have the player hit the bird.

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