Jump to content

Phaser 9patch support


Castellvi
 Share

Recommended Posts

Hello! 

I want to create my own buttons with some tool like "draw 9 patch" (so that they scale correctly) and use them in Phaser, but as I see, Phaser does not support it. Are there any plans to make phaser compatible with that technology?

 

I found this post, but it didn't help me because i have my buttons packed in an atlas and I load them in the game as a custom class that inherits from "Phaser.Button" class and resizes the image depending on the label size it contains, I don't load it as an image as the example shows, and I don't know how can I make it work this way.

 

For the moment, I'll create multiple buttons of multiple suizes, but I'd like to avoid that, asi it is not very efficient :/

 

Example of the constructor of my CustomButton class:

function CustomButton(x, y, atlas, callBack, btnName, strLabel, intFontSize) {	Phaser.Button.call(this, game, x, y, atlas, callBack, this,                        btnName + 'Up',  btnName + 'Up',  btnName + 'Down');    this.intFontSize = intFontSize || 50;    this.strLabel = strLabel || '';    this.inputEnabled = true;    game.add.existing(this);    this.anchor.setTo(0.5, 0.5);        var intScale = Tools.prototype.getScale();    if (strLabel == undefined) {        this.scale.setTo(intScale);    }    else {        this.lblButton = game.add.text(x, y,  this.strLabel,         { font: this.intFontSize + 'px Arial', fill: '#ffffff'});        this.lblButton.anchor.setTo(0.5, 0.5);        this.width = this.lblButton.width + (180*intScale);        this.height = this.lblButton.height + (40*intScale);        }    }
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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