Array Spawn Enemy Problem?

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

  • Why not set animation to choose("animation1","animation2","animation3","animation4")

  • Without a capx it's hard to see where it's going wrong, but littlestain's efficient suggestion should work perfectly.

  • Thanks works great. Not sure why i didn't consider that haha

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • just add the condition:

    sprite on collision with

    sprite animation1 is playing

    destroy

  • okay brilliant

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