Hello to all.
If you look around the many tutorials and capx examples about arrays you most likely saw a method were a single sprite object loads all monsters types sprites (just an example) and use their animation frames to reference each monster that should take data from the array.
I want to avoid that method, at least, for complex objects like enemies. But all examples use this animation frame method and i get stuck eventually.
There's a popular array example made by Kyatric explaining arrays and how to loop through it (it's called MyMiniRPG.capx
) and use the animation frame method.
I want to convert that example to use individual object types per monster grouped in a family (families could be avoided for now if you want) but i can't grasp the right method.
Let's say we have a 2d array of 50 monsters, X reference the index of each monster and Y reference each attribute of each monster.
Now we create each monster as a separate object type with instance variables to load and save data taken from the array (Or use a "Monsters" family instance variables).
Now imagine some kind of spawner object in the level spawning random monsters using the array data to "fill" each monster instance variables giving each one their particular attributes.
How should i proceed without looping the array using animation frames as reference? I don't supposed to know the exact x (index) position of a particular monster in the array so i have to relay on loopindex somehow.
Did you ever used arrays to load data to an object type looping the indexes without relying in the animation frame method?
I can't give a .capx file because there's nothing until you take data from the array. But below i leave Kyatric's example, if you can do the same he did but using individual object types per monster and a different looping method i will be saved. Or point me some directions and i will follow from there.Link to Kyatric's array example:http://www.scirra.com/forum/forum_posts.asp?TID=48528&PID=305024&title=rpg-problem#305024