Array Spawn Enemy Problem?

Get help using Construct 2

Post » Sun Apr 19, 2015 5:58 pm

I'm making a game that involves 4 enemies. When spawning, one of the enemies will be chosen at random using an array.

The way i did this was by creating a sprite and within the sprite add 4 seperate animations(being the 4 enemies)
Then i coded the array as follows.....

On start of layout > Array > Enemies > Push Back "names of enemies" on X axis

and for spawning it and selecting the enemy i used the following

System > every random (1,2) > Create enemy > layer 1 at x , y
> Enemy > Set animation to > (Enemy.At( floor(random(Enemy.Width)) )



Now the problem is that when the enemy is created it should select one of the 4 enemies from the animation at random, which it does. However the enemy that is the default animation (the first animation/Main Sprite) is spawned much more frequently than the others??
B
8
S
2
Posts: 146
Reputation: 1,132

Post » Sun Apr 19, 2015 6:37 pm

Why not set animation to choose("animation1","animation2","animation3","animation4")
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 Apr 20, 2015 5:59 pm

Without a capx it's hard to see where it's going wrong, but littlestain's efficient suggestion should work perfectly.
B
15
S
5
G
7
Posts: 876
Reputation: 5,650

Post » Tue Apr 21, 2015 2:58 pm

Thanks works great. Not sure why i didn't consider that haha
B
8
S
2
Posts: 146
Reputation: 1,132

Post » Tue Apr 21, 2015 4:25 pm

But when i need to write animation1 > on collision with > xyz > destroy

The problem is that each animation gets destroyed by a different object and because they are animations it only lets me select the 1 sprite that is comprised of the animations as opposed to the animations themselves.
B
8
S
2
Posts: 146
Reputation: 1,132

Post » Tue Apr 21, 2015 5:04 pm

just add the condition:

sprite on collision with
sprite animation1 is playing
> destroy
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 » Tue Apr 21, 2015 5:59 pm

okay brilliant
B
8
S
2
Posts: 146
Reputation: 1,132


Return to How do I....?

Who is online

Users browsing this forum: adamebastin, Bro7hers, korbaach, plinkie and 7 guests