JoekrJESUS Posted June 27, 2018 Share Posted June 27, 2018 Hey. I struggle with a problem. My SlickUI plugin won t work from custom object ? That ' s my code UI.js var SUI = function (slickUI) { this.UI = slickUI; this.HPpanel = null; this.healthSlider = null; this.set(); }; SUI.prototype.set = function() { this.healthBar(); }; 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); slickUI.load('ui/kenney.json'); } function create() { game.physics.startSystem(Phaser.Physics.ARCADE); 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() { //game.debug.geom(Player.aimCircle); //console.log(Player.aimCircle); } 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 More sharing options...
Recommended Posts