javascript - Phaser not rendering objects created in group -
i'm new phaser , can't seem make object created visible no matter what.
here js code:
var game = new phaser.game(448, 448, phaser.auto, '', { preload: preload, create: create, update: update }); function preload () { game.load.image('tabuleiro','assets/tabuleiro.png') game.load.spritesheet('devil','assets/devil.png',32,32); var capetinhas; } function create (){ capetinhas = game.add.group(); game.add.sprite(window.width,0,'tabuleiro'); //loading background game.add.sprite(128,128,'devil'); // works capetinhas.create(32,32,'devil'); // doesnt } function update (){ }
when put capetinhas.countliving()
on console prints 1, means object created not rendered.
thanks in advance.
try moving var capetinhas;
outside of preloader function has global scope. looks scope error - capetinhas
defined inside preload()
, create()
can't access variable.
Comments
Post a Comment