buryo Posted May 26, 2019 Share Posted May 26, 2019 Hello, I'm trying to generate a world map of tiles. But now I'm stuck, I'm getting an error which is impossible to understand. Maybe you will see what's going wrong: Quote Error: TypeError: Cannot read property '_pixiId' of undefined const MAP_WIDTH = 6400; // when I make this value 3200 or 832 it works else not const MAP_HEIGHT = 6400; // when I make this value 3200 or 832 it works else not const MAP_WIDTH = 6400; // when I make this value 3200 or 832 it works else not const MAP_HEIGHT = 6400; // when I make this value 3200 or 832 it works else not const TILE_WIDTH = 64; const TILE_HEIGHT = 64; map = [ Array.from({ length: MAP_WIDTH }, (_, i) => { if (i <= (MAP_WIDTH / 64) || i % (MAP_WIDTH / 64) === 0 || i % (MAP_WIDTH / 64) === (MAP_WIDTH / 64) - 1 || i >= (Math.pow(MAP_WIDTH / 64, 2)) - (MAP_WIDTH / 64)) { return 1 } return 0 }) ] createMap = () => { const cols = MAP_WIDTH / TILE_WIDTH; const rows = MAP_HEIGHT / TILE_HEIGHT; for (let i = 0; i < this.map.length; i++) { const layer = this.map[i]; for (let j = 0; j < rows; j++) { for (let k = 0; k < cols; k++) { const imageType = layer[j * cols + k]; let tile = PIXI.Sprite.from(this.images[imageType]); tile.x = k * TILE_WIDTH; tile.y = j * TILE_HEIGHT; tile.width = TILE_WIDTH; tile.height = TILE_HEIGHT; this.container.addChild(tile); } } } } Quote Link to comment Share on other sites More sharing options...
xerver Posted May 27, 2019 Share Posted May 27, 2019 Do you have a running example we can debug? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 27, 2019 Share Posted May 27, 2019 Yeah, demo would be a good thing Anyway, even if we debug it and find the bug: i recommend to read my tilemap implementation for v5, it was somewhere here: https://github.com/ivanpopelyshev/pixi-starfighter . It has general algorithm that allows not to spawn 100x100 or 1000x1000 tiles for the map and saves a lot of memory and performance. When I approve port of pixi-tilemap from v4 it will be even faster. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.