addLevel(map: string[], opt: AddLevelOpt, parent?: GameObj): GameObj<PosComp | LevelComp>
Construct a level based on symbols.
param
map- The map data.
param
opt- The level options.
param
parent- The parent object of the level. Defaults to root.
addLevel([
" $",
" $",
" $$ = $",
" % ==== = $",
" = ",
" ^^ = > = &",
"===========================",
], {
// define the size of tile block
tileWidth: 32,
tileHeight: 32,
// define what each symbol means, by a function returning a component list (what will be passed to add())
tiles: {
"=": () => [
sprite("floor"),
area(),
body({ isStatic: true }),
],
"$": () => [
sprite("coin"),
area(),
pos(0, -9),
],
"^": () => [
sprite("spike"),
area(),
"danger",
],
}
})
returns
A game obj with the level.
since
v2000.0
group
Level