Replies: 1 comment 2 replies
-
HI @ufukbakan ! Good question, you can use both Actors/TileMaps depending on your preference and needs. I'll update the documentation with more examples of usage!
const tileMap = new ex.TileMap({
name: 'tilemap',
pos: ex.vec(0, 0),
tileWidth: 32,
tileHeight: 32,
rows: 10,
columns: 100
});
for(let tile of tileMap.tiles) {
if (tile.y > 5) {
// floor that is solid with a graphic!
tile.solid = true;
tile.addGraphic(blocks);
}
} If you don't want to build TileMaps by hand you could look into the excalibur tiled plugin to load external maps https://github.com/excaliburjs/excalibur-tiled Another strategy using Actors: you could create 10 320x32 Actors and place them horizontally. You might use actors if you aren't going to be aligned to a grid, or you have features that need to move around independently. Somthing like this: for (let i = 0; i < 10; i++) {
const wall = new ex.Actor({
x: i * 32,
Y: 300,
width: 32,
height: 32,
})
wall.graphics.use(blocks);
game.add(wall);
} |
Beta Was this translation helpful? Give feedback.
-
Are walls/platforms actors too?
If yes then assume that I've 32x32 single wall sprite, but i want to create a wall platform 320x32 which needs its sprite to be repeated 10x in horizontal direction. How can i do that?
I read tilemap documentation but it really is not helpfull it only shows constructor arguments it doesnt tell how to bind it to an actor or to scene?
Beta Was this translation helpful? Give feedback.
All reactions