Search the Community
Showing results for tags 'pixi-tilemap'.
-
I am using "pixijs/pixi-tilemap" library to render maps exported from Tiled, but the rendering frame rate is low. I am newbie and I guess there may be a problem with the rendering loop logic, My thinking is as follows: I have several rendering layers(PIXI.display.Layer) in my game, I call them 'RenderingLayer', there are several cameras in the game (inherited from PIXI.Container), each camera can render multiple 'RenderingLayer' And output to RenderTexture, finally use the PIXI.Sprite group to render the final result according to the depth property of the camera. I use the ECS architecture to implement the game Code of RenderingSystem.update: for ( const camera of this.cameraComponents ) { if ( camera.renderingLayers.length === 0 ) { continue; } // clear stage $app.stage.removeChildren (); // add current rendering camera $app.stage.addChild ( camera.cam ); // collect camera rendering layer for ( const layerName of camera.renderingLayers ) { if ( $app.renderingLayers.has ( layerName ) ) { let layer = $app.renderingLayers.get ( layerName ); if ( layer.visible ) { camera.cam.addChild ( layer ); } } } // rendering camera result Graphics.render ( $app.stage, camera.renderTexture, this.renderTarget ); // clear camera.cam.removeChildren (); } // render final result this.renderSprite.removeChildren (); for ( const camera of this.cameraComponents ) { this.renderSprite.addChild ( camera.renderSprite ); } renderer.render ( this.renderSprite, null, true ); May be frequent use of removeChildren / addChild affects rendering performance?? I use the ECS architecture to implement the game, You can find the code for the RenderingSystem class here: js/ecs/systems/rendering_system.js. Another guess might be that I did not use the pixijs / pixi-tilemap library correctly.? see here: https://lihaochen910.github.io/RPGMakerProject/ code is here: https://github.com/lihaochen910/RPGMakerProject
-
First of all, sorry for my english. I just started with Pixi and was studying tilemaps, but I'm having gaps between the tiles whenever I scale by the factor of 0.01. Yes, i'm using PIXI.SCALE_MODES.DEFAULT = PIXI.SCALE_MODES.NEAREST; Here's what I I've got: PIXI.SCALE_MODES.DEFAULT = PIXI.SCALE_MODES.NEAREST; PIXI.loader .add('tileset', 'img/tileset.json') .load(setupMap); function setupMap() { var mapData = []; // Omitting bidimensional array with tiles for the sake of the example var map = new Container; var tilemap = new PIXI.tilemap.CompositeRectTileLayer(0, [], true); for(var coll = 0; coll < 100 * 48; coll++) { for(var row = 0; row < 100 * 48; row++) { if(mapData.hasOwnProperty(coll) && mapData[coll].hasOwnProperty(row)) { tilemap.addFrame(tileset.textures[mapData[coll][row]], coll*48, row*48); } else { break; } } } map.addChild(tilemap); stage.addChild(map); } // This fucks up everything document.addEventListener('mousewheel', mousewheel, false); document.addEventListener('DOMMouseScroll', mousewheel, false); function mousewheel(e) { var zoomOut = e.wheelDelta <= 0; map.scale.set(map.scale.x + (zoomOut ? -0.01 : 0.01)); }