update: function(dt) {
this._super(me.Entity, 'update', [dt]);
return true;
}
MelonJS will not redraw the screen if it doesn't have to. Returning true from an update method tells the engine that his entity needs to be repainted. So since nothing was returning true, nothing got painted after the play screen loaded. I'll update the tutorial to reflect this later tonight. Thanks a bunch for reporting the issue, and please don't hesitate to ask any further questions.
me.game.world.addChild(me.pool.pull("enemy"), 2);
me.game.world.addChild(me.pool.pull("enemy", 50, 50), 2);
me.game.world.addChild(new game.Player(), 1);
me.game.world.addChild(new game.Enemy(50, 50), 2);
Good catch on the lack of using pooling there. I'll double check the source code for the steps as well.
At this point, you should add #debug to the URL: http://localhost:8000/#debug and tap on the checkbox next to "hitbox" in the debug panel.
--
You received this message because you are subscribed to the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to melonjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
game.Message = me.Renderable.extend({
init: function (x, y, message, hexColor) {
this.message = message;
this._super(me.Renderable, "init", [x, y, 32, 32]);
this.font = new me.Font("Arial", 32, (new me.Color()).parseHex(hexColor));
},
draw: function (renderer) {
this.font.draw(renderer, this.message, this.pos.x, this.pos.y);
});
game.WinScreen = me.ScreenObject.extend({
onResetEvent: function() {
me.game.world.addChild(new me.ColorLayer("background", "#0f0f0f"), 0);
this.message = new (game.ModalMessage.extend({
init: function () {
this._super(game.ModalMessage, "init", [100, 100, "Alien Killer!", "#ffffff"]);
},
update: function(time) {
this._super(game.ModalMessage, "update", [time]);
if (me.input.isKeyPressed("shoot")) {
me.state.change(me.state.PLAY);
}
}
}));
me.game.world.addChild(this.message, 2);
}
});
--
You received this message because you are subscribed to a topic in the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/melonjs/tx_ECOFRz3Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to melonjs+u...@googlegroups.com.
game.Message = me.Renderable.extend({
init: function (x, y, message, hexColor) {
this.message = message;
this._super(me.Renderable, "init", [x, y, 32, 32]);
this.font = new me.Font("Arial", 32, (new me.Color()).parseHex(hexColor));
this.z = 200;
},
draw: function (renderer) {
this.font.draw(renderer, this.message, this.pos.x, this.pos.y);
},
update: function () {
return true;
}
});
game.WinScreen = me.ScreenObject.extend({
onResetEvent: function() {
me.game.world.addChild(new me.ColorLayer("background", "#0f0f0f"), 0);
this.message = new (game.Message.extend({
init: function () {
this._super(game.Message, "init", [100, 100, "Alien Killer!", "#ffffff"]);
},
update: function(time) {
this._super(game.Message, "update", [time]);
if (me.input.isKeyPressed("shoot")) {
me.state.change(me.state.PLAY);
}
}
}));
me.game.world.addChild(this.message, 2);
}
});