Search the Community
Showing results for tags 'nine'.
-
Hi guys, I'm new to Panda2 and I'm trying it out to see if it fit my requirements. My game will be UI intensive so I need few features that make my work a bit easier. One of these feature is the possibility to use Nine Patch for Button, Panel, etc. Something like this : https://phaser.io/news/2015/08/nine-patch-phaser-plugin Is it available for Panda2? If not how easy is to create custom control that allow me to have such behaviours? Are we able to set to a sprite a region of a texture?
-
So a few months ago I have to deal with the kind of nine patch image. I see that many game engines and app frameworks support this kind of image, but Phaser doesn't. I did google around and found this gist on the thread ninepatch-images-possible-with-phaser. However, the code has some very serious problems: The class consider the image should be divided in to equals part horizontally and vertically, and we all know that most time, that is not the case; It creates new texture every time you create new instance of the same nine patch image, that is a big waste of memory and performance; The code is outdated since there have been so many changes in Phaser in the last few versions, would definitely crash on 2.4; The nine patch image must be standalone, you cannot load it from a spritesheet or a texture atlas.I created my own solution, and it works very well in my works. So today I polish the code to share to all of you This is the Nine Patch Plugin for Phaser. You can try out the demo on this codepen. For usage, read the readme on the github repository. For more technical details check out this post. The source is available for download from latest release or the github repository or via bower:bower install --save nine-patch-phaser-pluginBtw, since Phaser.NinePatchImage actually extends Phaser.Image, so you can do anything that you can do on a Phaser.Image instance with a Phaser.NinePatchImage instance. However, in some cases, like with anchor, you have to run the method UpdateImageSizes afterward for the NinePatchImage to be displayed correctly. Cheers!