Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Tony Colston
Tony Colston

Posted on

     

quick textures without extra files in Phaser3

A really quick simple trick to generate textures to use in Phaser3.

You can use simple arrays of strings. The values are hexadecimal. You call another method that will generate the texture from the strings.

exportletbar=["11111111111111111111","1.FEDCBA9876543210.1","11111111111111111111",];this.textures.generate("bar",{data:bar,pixelWidth:16});this.textures.generate("bar8",{data:bar,pixelWidth:8});
Enter fullscreen modeExit fullscreen mode

Once you have the textures generate with the keys. Then you can use these as if they were image files all along.

letimg=this.add.image(0,0,"bar");img.setOrigin(0,0);letimg2=this.add.image(0,64,"bar8");img2.setOrigin(0,0);
Enter fullscreen modeExit fullscreen mode

The palette values look like they come from here
https://androidarts.com/palette/16pal.htm

The Phaser3 documentation calls this Arne16. See here:https://photonstorm.github.io/phaser3-docs/Phaser.Textures.TextureManager.html

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

cofounder of CrossBrowserTesting.com. uber nerd. ui challenged. gamdev
  • Location
    Memphis
  • Work
    former founder/Development Manager at CrossBrowserTesting.com
  • Joined

More fromTony Colston

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp