Jump to content

get of atlas texture in bitmapData


TreeLoys
 Share

Recommended Posts

I load atlas

game.load.atlas('menu-border', 'img/rpanel.png', 'img/rpanel.json')

in img/rpanel.json

{"frames": [{	"filename": "ng-top",	"frame": {"x":137,"y":0,"w":133,"h":27},	"rotated": false,	"trimmed": true,	"spriteSourceSize": {"x":0,"y":0,"w":133,"h":27},	"sourceSize": {"w":133,"h":27}}],"meta": {	"app": "TreeTeamsSpriteAtlasEditor",	"version": "1",	"image": "rpanel.png",	"format": "RGBA8888",	"size": {"w":270,"h":84},	"scale": "1"}}

I create bimapData

var bg_menu = game.make.bitmapData(600, 400);

I need copy "ng-top" frame in rigth-top angle $bg_menu

 

pseudo:

bg_menu.copyRect('menu-border', 'ng-top', 567, 0);bg_menu.addToWorld();

but it does not work  :(

Link to comment
Share on other sites

After 5 hours of digging source Phaser, I created a function that satisfied me. I would like to see this feature in the new version of the Phaser.

 

function copyRectArea(bmd, keyArea, keyFrame, x, y, alpha, blendMode, roundPx){	var frame =  game.cache.getFrameData(keyArea).getFrameByName(keyFrame);	var area = new Phaser.Rectangle(frame.x, frame.y, frame.width, frame.height);	bmd.copyRect(keyArea, area, x, y, alpha, blendMode, roundPx);}

Using:

var bg_menu = game.make.bitmapData(600, 400);var area = new Phaser.Rectangle(137, 0, 133, 27);copyRectArea(bg_menu, 'menu-border', 'ng-top', 167, 0);bg_menu.addToWorld();
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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