Jump to content

SlickUi in object Won t work


Recommended Posts

Hey. I struggle with a problem. My SlickUI plugin won t work from custom object 😕 That ' s my code



var SUI = function (slickUI) {
    this.UI = slickUI;

    this.HPpanel = null;

    this.healthSlider = null;



SUI.prototype.set = function() {

SUI.prototype.healthBar = function () {
    this.UI.add(this.HPpanel = new this.UI.Element.Panel(10,10,300,60));
    this.HPpanel.add(this.healthSlider = new this.UI.Element.Slider(16,100, 32));

game.js  --- I cutted some code from it, cuz file was too long to copy it here, don t mind useless variables

var game = new Phaser.Game(1440, 920, Phaser.AUTO, 'example', { preload: preload, create: create, update: update, render: render });

var tileMap1;

var Mouse, Input, Pointer, colHD, slickUI, SUI;
var img, Player, Enemy;

var panel, button;

var timing = 0;

var Wkey, Skey, Dkey, Akey, Rkey;

function preload() {

    slickUI = game.plugins.add(Phaser.Plugin.SlickUI);

function create() {


    Wkey = game.input.keyboard.addKey(Phaser.Keyboard.W);
    Skey = game.input.keyboard.addKey(Phaser.Keyboard.S);
    Dkey = game.input.keyboard.addKey(Phaser.Keyboard.D);
    Akey = game.input.keyboard.addKey(Phaser.Keyboard.A);
    Rkey = game.input.keyboard.addKey(Phaser.Keyboard.R);


    colHD = new CollisionsHandler(game.physics.arcade);

    SUI = new SUI(slickUI); // HERE IS MY SLICK UI 


function update() {

function render() {

The Error is 

TypeError: Cannot read property 'Panel' of undefined
    at SUI.healthBar (UI.js:17)
    at SUI.set (UI.js:13)
    at new SUI (UI.js:8)
    at Object.create (game.js:60)
    at Phaser.StateManager.loadComplete (phaser.js:31120)
    at Phaser.Loader.finishedLoading (phaser.js:80678)
    at Phaser.Loader.processLoadQueue (phaser.js:80625)
    at Phaser.Loader.asyncComplete (phaser.js:80707)
    at Phaser.Loader.xmlLoadComplete (phaser.js:81619)
    at Phaser.Loader.<anonymous> (phaser.js:81439)


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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