Jump to content

9-images in Phaser


Tom Atom
 Share

Recommended Posts

Hi, yesterday I wrote code, that adds support for 9-patch images into Phaser. New NineImage class is created with new (Phaser 2.3.0) component-like approach (while I am not sure, whether I did everything 100% well).

 

I wrote tutorial about it on my blog: http://sbcgamesdev.blogspot.com/2015/05/phaser-tutorial-adding-9-patch-image.html You can also download it there.

 

As it derives from sprite and uses Phaser components, it can be scaled, rotated, anchored, ...

 

image like this:

post-12887-0-82465400-1430737040.png

 

can be easily used like this:

post-12887-0-63278400-1430737040.jpg

Link to comment
Share on other sites

  • 6 months later...

It's worth noting that the Phaser.Canvas.create() parameter list changed (in this commit) and broke Tom's NineImage code, currently it won't work with Phaser 2.4.3 and above.

 

The changed function now requires the object parent to be the 1st parameter, so it's easy to find the few occurances in the NineImage code and add this.  You'll know you've hit this problem if your 9patch's are coming out with a width that should be the height and a height of 256.

 

Since this version of NineImage, Tom has generously offered an alternative version (here).

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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