-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Is there a way to use this with @pixi/spritesheet
?
#163
Comments
Tilemap is already optimized to work with spritesheets. |
Is there example code anywhere? I can get the textures from the spritesheet and create an animated sprite with const textures = spritesheet.animations[key];
const sprite = new AnimatedSprite(textures) But I have no idea how to create a TileSheet with the textures from the spritesheet. const tilemap = new Tilemap(spritesheet.baseTexture);
const textures = spritesheet.animations[key];
tilemap.tile(textures[0], 0, 0); |
I tried with the latest pixi.js 8.1.0 and @pixi/tilemap 5.0.1, and I can now tile static textures with const tilemap = new Tilemap(spritesheet.textureSource);
const textures = spritesheet.animations[key];
tilemap.tile(textures[0], 0, 0); |
@earthiverse I'm not sure what is your exact use case, but remember, that animations in Tilemap are handled differently than in SpriteAnimations. SpriteAnimations changes texture (so, it's placement on spritesheet doesn't matter), but in Tileset all frames have to be in a fixed grid close to first tile. (you just provide number of frames and rows) - see basic example. Also, you actually may not need to put each individual sprite in the spritesheet, as you can just provide whole tileset TextureSource and place tile providing source position by hand:
This might be especially useful if you use some tilemap editor with fixed-tile tilemap image source. |
@ajur I can see how the code I posted is very misleading, sorry, I was just trying to get something working before moving on. I ended up with different issues using tilemap with a large number of tiles. They just stopped rendering. I do have a mix of animated and non-animated tiles in my project, but the animated tiles are only 3 frames. Making 3 RenderTextures, and just rendering the tiles to the textures is working well enough for me. |
Did you enable 32-bit indices? |
I did not. The readme on the main page says for use32bitIndex to "please use PixiJS v5.1.0", I guess I'll try again and see if it works on newer versions of PixiJS, too. |
I am currently adding tiles as individual sprites / animated sprites to a container, but performance is not ideal on large maps, and I was wondering if this could help me improve performance.
I'm using Typescript, and I have a sprite sheet that I created and I want to use.
The text was updated successfully, but these errors were encountered: