Monster Array

0 favourites
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • I have many monsters on my map, if click on it, it destroys, on destroyed - system creates that monster at that position. Now this works, but i dont want to do it like 100000 times.

    So I was wondering if this can work in an array.

    On my txt file I wrote

    1,3516,4059

    where 1 is the value of the monster like an ID, and 3516 is the x-coordinated, and 4059 is the y-coordinated.

    this can work right? or not ?

  • if click on it, it destroys...

    Click on what?

    On my txt file I wrote 1,3516,4059

    You can do it, but it's a very ineffective solution. (again)

    Filling this array with numbers will take you more time than placing monsters manually on the layout. Besides, what if you want to make some changes to the map in the future? You will need to change all numbers in the array.

  • click on the monster ID (1) - destroy

    on destroyed - system creates monster on layer 0 (3516, 4059)

    monster ID = 1

    on destroyed - system creates monster on layer 0 (4034, 3139)

    monster ID = 2

    so i need to do this?

  • So you only show one monster at a time? When one monster is destroyed, then the next monster appears?

    You can put all these monsters on the layout and set them invisible, disable behaviors etc. Then simply enable them one by one.

    Or place spawn points on the layout (invisible sprites). When you need to spawn a new monster, pick first spawnpoint, spawn a monster, destroy spawnpoint. It will still be easier than creating and maintaining that array.

    The array only makes sense if you generate all these thousands of coordinates automatically, for example in Excel with some formula, or using some level builder.

  • I think I will use the spawn points, is easier :) and its working now.

    Thank you for your help.

  • There are actually hundreds of monsters in one map

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • i have over 30 monsters in one map.

    each monster is placed at a position on the map

    if click on a monster whose ID is = 1 destroy

    on destroyed - system creates monster ID = 1 on that position.

    and so on it goes

  • Is there a question?

  • It is going to be a lot of coordinates and lots of monsters.

    which one would work? the array or just make spawn points?

  • Both will work. Whatever is more convenient to you.

    Like I said, it will probably be easier to put all monsters on the layout (deactivated and invisible). When a monster with ID=1 is destroyed, pick monster with ID=2, set it visible and activate its behaviors.

  • i was thinking an array would be easy, if i use the spawn points i have to make 100 and more events.

    the monsters are all visible, my game is like a mmorpg. I want my monsters to spawn like the game called "Flyff"

    Now i need to figure out how to get it to work with an array

  • Why would you need 100 events???

    On Enemy destroyed
    	Variable tempID
    	set tempID to EnemyID
    
    	Enemy pick all
    	Enemy compare variable id=(tempID+1)
    		Enemy set visible
    

    That's it!

  • Or even easier with a function:

    On Enemy destroyed
    	Function call "ActivateEnemy" parameter: (Enemy.id+1)
    
    
    On function "ActivateEnemy" 
    Enemy compare variable id=Function.parameter(0)
    		Enemy set visible
    
  • Almost. You need to actually destroy the enemy, and move "On destroyed" event from sub-event to top level.

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