atlas information. See loader.getJSON
Optional
src: Image source
Optional
cache: booleanUse true to skip caching this Texture
// create a texture atlas from a JSON Object
game.texture = new me.TextureAtlas(
me.loader.getJSON("texture")
);
// create a texture atlas from a multipack JSON Object
game.texture = new me.TextureAtlas([
me.loader.getJSON("texture-0"),
me.loader.getJSON("texture-1"),
me.loader.getJSON("texture-2")
]);
// create a texture atlas for a spritesheet with an anchorPoint in the center of each frame
game.texture = new me.TextureAtlas(
{
framewidth : 32,
frameheight : 32,
anchorPoint : new me.Vector2d(0.5, 0.5)
},
me.loader.getImage("spritesheet")
Create an animation object using the first region found using all specified names
Optional
names: string[] | number[]list of names for each sprite (if not specified all defined names/entries in the atlas will be added) (when manually creating a Texture out of a spritesheet, only numeric values are authorized)
Optional
settings: objectAdditional settings passed to the Sprite contructor
// create a new texture object under the `game` namespace
game.texture = new me.TextureAtlas(
me.loader.getJSON("texture"),
me.loader.getImage("texture")
);
// create a new Animated Sprite
let sprite = game.texture.createAnimationFromName([
"walk0001.png", "walk0002.png", "walk0003.png",
"walk0004.png", "walk0005.png", "walk0006.png",
"walk0007.png", "walk0008.png", "walk0009.png",
"walk0010.png", "walk0011.png"
]);
// define an additional basic walking animation
sprite.addAnimation ("simple_walk", [0,2,1]);
// you can also use frame name to define your animation
sprite.addAnimation ("speed_walk", ["walk0007.png", "walk0008.png", "walk0009.png", "walk0010.png"]);
// set the default animation
sprite.setCurrentAnimation("simple_walk");
// set the renderable position to bottom center
sprite.anchorPoint.set(0.5, 1.0);
Create a sprite object using the first region found using the specified name
name of the sprite
Optional
settings: objectAdditional settings passed to the Sprite contructor
Optional
nineSlice: boolean = falseif true returns a 9-slice sprite
// create a new texture object under the `game` namespace
game.texture = new me.TextureAtlas(
me.loader.getJSON("texture"),
me.loader.getImage("texture")
);
...
...
// create a new "coin" sprite
let sprite = game.texture.createSpriteFromName("coin.png");
// set the renderable position to bottom center
sprite.anchorPoint.set(0.5, 1.0);
...
...
// create a 9-slice sprite
let dialogPanel = game.texture.createSpriteFromName(
"rpg_dialo.png",
// width & height are mandatory for 9-slice sprites
{ width: this.width, height: this.height },
true
);
return the source texture for the given region (or default one if none specified)
Optional
region: objectregion name in case of multipack textures
A Texture atlas class, currently supports :