Jump to content

Draw a lot of tiles to make one object


verybigelephants
 Share

Recommended Posts

Hello!

i've been trying to build my level scene from a lot of small rectangular tiles (it's important for the game to be this way from an aesthetic point of view). however, when i use this classic object approach

 

Quote

    var tile = new PIXI.Sprite(use_texture);
        tile.x = x * tile_size;
        tile.y = y * tile_size;
    gfx_container.addChild(test);

and add a lot of them (my level has a lot of them) the cpu/gpu/i don't know what goes crazy this is probably because they are all sprite objects

so i wanted to draw these tiles one by one, once at the start and then handle the big thing as one object. how would i go about doing that?

i have found a method beginTextureFill, but they told me here https://github.com/pixijs/pixi.js/issues/5332 it's only in dev build yet and i don't believe there wasn't a way how to draw a lot of graphics into one container and consider them a single object before

could somebody help me out?

Link to comment
Share on other sites

You could draw the container into a single rendertexture and then use that as a sprite.

var rt = new PIXI.RenderTexture( new PIXI.BaseRenderTexture(width, height), new Rectangle(0,0, width,height));
renderer.render(gfx_container, rt);

var bgSprite = new Sprite(rt);
maincontainer.addChild(bgSprite);

You could also use cacheAsBitmap to that container to make the same effect.

If you have same texture for each sprite, then you could use TilingSprite.

 

How many tiles in total and do you have different textures  for those?

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...