Destroy one instance of a sprite created at start

Get help using Construct 2

Post » Sat Apr 07, 2012 7:30 am

I've beat my head against this for a couple days, and have read a lot of the posts on here about dealing with instances through UID's, select n'th, etc.

Here is a .capx of what I am attempting,

http://dl.dropbox.com/u/30187917/instance_on_creation.capx

I want to create enemies at specific locations, the enemies are represented by the same sprite, and the HP for each enemy is stored in an array. I use the array to populate 2 values, a maximum and minimum HP for each enemy location. When a minimum HP variable reaches 0 I want the enemy at that location to be destroyed. My problem is, regardless of how I set this up, it's very difficult for me to specifically (and elegantly) assign which instance of the sprite gets destroyed.

Any suggestions would be greatly appreciated!
B
9
Posts: 59
Reputation: 997

Post » Sat Apr 07, 2012 8:40 am

first, you have four sprite instances - one that is on the right side is your Sprite.Instance=0, top left is Sprite.Instance=1, midle left is Sprite.Instance=2 and bottom left is Sprite.Instance=3. Second, when enemyhp1_hpMin=0 it will destroy Sprite.Instance=0 - right Sprite, and number of instance will change so the second sprite (former Sprite.Instance=1) will be Sprite.Instance=0, and it will be destroyed, and third sprite will become Sprite.Instance=0 et cetera.

Use private variable.podpathos2012-04-07 09:09:43
B
12
S
2
G
2
Posts: 96
Reputation: 1,583

Post » Sat Apr 07, 2012 10:07 am

[QUOTE=podpathos] first, you have four sprite instances - one that is on the right side is your Sprite.Instance=0, top left is Sprite.Instance=1, midle left is Sprite.Instance=2 and bottom left is Sprite.Instance=3. Second, when enemyhp1_hpMin=0 it will destroy Sprite.Instance=0 - right Sprite, and number of instance will change so the second sprite (former Sprite.Instance=1) will be Sprite.Instance=0, and it will be destroyed, and third sprite will become Sprite.Instance=0 et cetera.

Use private variable.[/QUOTE]

Thanks for getting back to me! Your point about the sprite instances makes sense. I'll try using an instance variable, and if I get it working I'll post my results. Thanks again man, very informative :)
B
9
Posts: 59
Reputation: 997

Post » Sat Apr 07, 2012 11:03 am

New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Sat Apr 07, 2012 8:20 pm

[QUOTE=Kyatric] More commented picking for you in capx[/QUOTE]

Glorious! This makes so much more sense then what I was attempting, thank you so much!
B
9
Posts: 59
Reputation: 997


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 17 guests