Jump to content

User NineSlice as key for creation of new Sprite

Yehuda Katz

Recommended Posts


I am using NineSlice plugin to reduce size of images. The plugin itself works fine but it creates sprite as a result, which later can be added to stage. I would like to use that newly created sprite as a key/bitmapdata for creation of new sprite.

1) I googled to search a way to add it to cache so I can refer to it via key but without any results

2) I came up with solution to create bitmapdata, draw newly created sprite and then use that bitmap data for sprite

var slice = new PhaserNineSlice.NineSlice(this.game, 0, 0, 'default', 'circle_blue.9.png', 60, 60, {top: 21, bottom: 21, left: 21, right: 21});
var bitmap = new Phaser.BitmapData(this.game, 'slice', 60, 60);
stage_map.createFromObjects('menu', 'back', bitmap, null, true, false, this.menu);

Everything works fine but I do not like that extra operation and 3 lines of code, is that a way to use sprite to create new one without intermediate bitmapdata?

Thanks in advance

Link to comment
Share on other sites


  • Recently Browsing   0 members

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