Splitting enemy

Get help using Construct 2

Post » Sat Oct 08, 2011 1:50 am

I have an animation for an enemy type which splits into two of itself. There are two image points in the animation for where to spawn the two new enemies however my code does not work:



It spawns one enemy at image point 1 but none at image point 2. Strange things also happen.

Any tips?sqiddster2011-10-08 01:52:34
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,390

Post » Sat Oct 08, 2011 1:58 am

I couldn't tell you exactly what's going wrong there, but from the looks of it Construct might be getting confused that there's so many "Enemy"s running around. The problem's probably in picking instances of it. I have trouble with that myself, so I'll save us all the headache of me trying to offer a solution.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Sat Oct 08, 2011 2:57 am

i'm not sure, but i believe it's the order of your events for the animation.

you destroy the enemy, then you try to make reference to it, for spawning. i think you have to make your references first while it still 'exists', then destroy it. you can make it invisible while you do your spawning.

hope that helps...
B
50
S
17
G
15
Posts: 1,029
Reputation: 26,289

Post » Sat Oct 08, 2011 3:25 am

not sure exactly but feels like construct is not picking the right instance . Least that's what it seemed like when I recreated your example.    But I did get it to double the way I expected by making each Spawn action a sub-event of the initial Event as a way to keep it picking the original
if that helps.
example .capx

Warning the example .capx makes a lot of sprites rather fast. onzephyr2011-10-08 03:26:07
B
83
S
12
G
9
Posts: 99
Reputation: 9,478

Post » Sat Oct 08, 2011 5:17 am

@onzephyr Your method is good but there are a few bugs when I use it for my purposes. See the problem here:

http://dl.dropbox.com/u/41931267/Splittr.capx
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,390

Post » Sat Oct 08, 2011 5:58 am

It seems to be splitting correctly. What is it not doing. Or doing that's unexpected?

nice smooth animation by the way.
B
83
S
12
G
9
Posts: 99
Reputation: 9,478

Post » Sat Oct 08, 2011 8:42 am

Well as you can see the correct amount of sprites are being created but they are jumping to strange positions...
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,390

Post » Sat Oct 08, 2011 9:47 am

Is this closer to what you were expecting?

http://dl.dropbox.com/u/22615804/Splittrer.capx

I would say that the ordering and unspecific instructions are the problem, but I've tried with and without a For Each condition and it functions pretty much equally (I left it in though). I've placed the destroy event before and after the creation events, same thing.

So I changed it from the object itself spawning the new objects to simply creating them with the system create object action. what you can do with spawn object from object you can do with system create object, just better imo. I think there may be an issue with how c2 picks objects that are created by other objects. However, I'm just guessing.inkBot2011-10-08 09:52:35
B
73
S
20
G
10
Posts: 524
Reputation: 9,896

Post » Sat Oct 08, 2011 10:59 am

@inkbot It seems to work. Will there be problem when there are all different enemies everywhere splitting at different times? That is what I need.

EDIT: never mind, it works fine (I took out the 'for each' loop).

Here is a (quite cool) example .capx

http://dl.dropbox.com/u/41931267/Splittr.capxsqiddster2011-10-08 11:10:49
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,390


Return to How do I....?

Who is online

Users browsing this forum: anty21ro, badmoodtaylor, Megavolt, Yahoo [Bot] and 12 guests