You have a packs.json file, where all packs or game modes are defined and each one has a "level" property, which defines how many levels are there in this pack.
How do I add level info directly into the packs.json? For every level I have a different spawn table, which I save directly on a .lua table file like this:
Each line is a level and each row is a different enemy with a spawn time in milliseconds. I think it would be better to put that in packs.json, but I don't know how it's syntax works.
Each pack has several levels, each level has several enemies, each enemy has "type" and "time". I tested it and it works. The only problem could be when I put 50 or more enemies on each level.
Defined above you could use an editor worlds, as Tilemap, for deploying everything that will contain the level easier. Here is official source, for loaded worlds, you've created with Tilemap https://github.com/gideros/Isometric-Tilemap
At first I didn't think Tilemap would be necessary. Because my character doesn't walk through a stage, but there are many enemies appearing constantly. I'm gonna check that link, thanks!
@HubertRonald I'm having a lot of enemies and a lot of options for them, and my tables for them are getting to big. I want to use a tilemap but I don't want to use the packs.json option cause what I want is to design the levels easily. Something like these:
The 0 are empty spaces and the other numbers are different enemies. How is that done? do I have to save that into a .txt file? Is that a good option for an android game? Should I save it on another file type?
Hi @somezombiegm For your case, I would do the following
-- name file: -- Stage4of36.lua for example-- after inside your file (Stage4of36.lua)return{
000000000000000020000000000000
000101001000100000000000000000
000000000000000020000000000000
000002002000003000000000000000
000000000000000000000000000000
000000000000001110000000000000
000000000000001000000000000000
}-- with commas numbers
in your engine game you would have than load for example "Game/Stages/Stage4of36.lua"
engineGame = Core.class(Sprite)function engineGame:init()--[[
It dependent of where you've your file in your project
(numbers 4 (world) and 36 (level)
(you could have only levels in your game)
you should implement them with
data.save and a global variable like "sets" in your code
but you'll have that define each file stage1fo1.lua, stage1fo1.lua,...)
]]
self.infoLevel =loadfile(table.concat{"Game/Stages/Stage",4,"of",36,".lua"})()--*--*
self:deployFoes()--*--*end
To implement the enemies my suggestion is that you you elaborate a master class that contains all its properties:
function engineGame:deployFoes()
self.foesGame={}for i=1, #self.infoLevel doif self.infoLevel[i]~=0then-- I suppose than 1,2 and 3 are enemies
self.foesGame[#self.foesGame+1]= foes.new(self.infoLevel[i])--[[
if you had implemented a camera class otherwise
self:addChild(self.foesGame[#self.foesGame])
]]
self.camera:addChild(self.foesGame[#self.foesGame])end
But as I said you, all depends on what you want to do, this is only a possible solution, there may be other.
I want to use a tilemap but I don't want to use the packs.json option cause what I want is to design the levels easily.
This is not necessarily true, you can use tilemap without than you use packs.json, as I mentioned, it all depends on what you want to implement and most importantly how you feel comfortable, as long as this doesn't affect performance of your code.
@HubertRonald Thanks for the response. Something like that is what I'm looking for, I will work on it as soon as I can and come back if I get stuck or something LOL.
@HubertRonald I don't know how loadfile works, but I put the level info on a new file like you said and called it waveTest.lua and got this error message:
waveTest.lua:3: '}' expected (to close '{' at line 1) near '000101001000100000000000000000'
Comments
That part i get, but how do a link them to the levels i create. It alwais opens level file, how do a link to others files? Like level_1_1, level_1_2?
It was so easy. Thanks...
How do I add level info directly into the packs.json? For every level I have a different spawn table, which I save directly on a .lua table file like this:
{"packs":[
{"name":"Intro pack","levels":6},
{"name":"First pack","levels":20},
{"name":"Second pack","levels":20},
{"name":"Third pack","levels":12}
]}
What I want to do is: on "levels" instead of specifying how many levels there are, put the levelSpawnData table there. Please help me out.
Here is official source, for loaded worlds, you've created with Tilemap
https://github.com/gideros/Isometric-Tilemap
[-] Liasoft
At first I didn't think Tilemap would be necessary. Because my character doesn't walk through a stage, but there are many enemies appearing constantly. I'm gonna check that link, thanks!
It all depends on what you want to do, for example for my app, Paint pong I do not use the tilemap as you.
Well I think you can also take advantage of the tilemap to create small puzzle
[-] Liasoft
Likes: HubertRonald
[-] Liasoft
For your case, I would do the following
[-] Liasoft