Jump to content

Regenerate texture in render()


talamask
 Share

Recommended Posts

Hello

In Phaser 3.15 I am creating a texture using this.textures.generate passing an array of string arrays based on heights I generated with Perlin noise like this:

create() {
   this.textures.generate("map", { data: textureMap, pixelWidth: 5, pixelHeight: 5, palette: palette });
   this.add.image(0, 0, "map").setOrigin(0);
}

Result can be viewed in attachment.

How can I regenerate this texture in update() function based on another textureMap data? I understand that it can be inefficient to do it each frame, but I just want to know how to do it.

If I try directly to generate and add image with the same key Phaser complains that Texture key already in use: map

Thank you!

map.png

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...