Skip to content

An enchant.js plugin that let you use a texture atlas generated from TexturePacker easily.

Notifications You must be signed in to change notification settings

himatako/textureatlas.enchant.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

TexturePacker plugin for enchant.js

textureatlas.enchant.js is a plugin for enchant.js that make it very easy to use a texture atlas generated from Texture Packer in your enchant.js game/application.

How to use textureatlas.enchant.js

  1. Download Texture Packer

  2. Set the export setting to output JSON(Array)

  3. Create a texture atlas as usual. You will get two files, which are .json and .png files.

  4. Include textureatlas.enchant.js into your HTML file.

  5. Preload both the json file and the png file in your game.

    game.preload("res/atlas.png",
                 "res/atlas.json");
  1. Create a texture atlas and give it a name for later access.
	// Create a texture atlas called 'mainAtlas', using
	// atlas.json and atlas.png files
    enchant.TextureAtlas.createTextureAtlas(
    			'mainAtlas',
                game.assets['res/atlas.json'],
                game.assets['res/atlas.png']);
  1. Create an instance of a AtlasSprite class and use it as a normal enchant.js Sprite
	var bgSprite = new enchant.AtlasSprite('mainAtlas', 'bg_01.png');
	bgSprite.x = Core.instance.width/2 - bgSprite.width/2;
	this.addChild(bgSprite);
  1. You can also change the sprite's graphic quickly by reassigning the sprite identifier.
	bgSprite.spriteId = 'enemies-01.png';

About

An enchant.js plugin that let you use a texture atlas generated from TexturePacker easily.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published