Search the Community
Showing results for tags 'game.system.delta'.
-
Hello guys, I'm trying to get this code working: game.module( 'game.main').require( 'engine.core').body(function() { game.addAsset('box.png'); eNemies = game.Class.extend({ init: function(vel, px){ this.containerEnemies = new game.Container(); this.containerEnemies.addTo(game.scene.stage); this.sprite = new game.Sprite('box.png',px,500,{anchor: { x: 0.5, y: 0.5 }}); this.sprite.interactive=true; this.sprite.addTo(this.containerEnemies); this.sprite.touchstart = this.sprite.click = function(){ this.remove(); } }, update: function(){ if(game.system.paused != true){ speedRandom = Math.floor(Math.random() * 280) + 100; this.sprite.position.y -= speedRandom * game.system.delta; } }, remove: function(){ game.scene.removeObject(this); } });game.createScene('Main', { backgroundColor: 0x44cce2, init: function() { eNemiesArray = []; i = 0; createEnemies = function(){ posXrandom = Math.floor(Math.random() * 500) + 1; this.eNemiesArray[i]=new eNemies(120,posXrandom); i++; setTimeout("createEnemies();", 250); } createEnemies(); }, });Enemies creation is working, enemies onTouch event also, but the update function, to move every enemies seems to not work, can you help me to understand what's wrong? Thank you
- 10 replies