Search the Community
Showing results for tags 'setScene'.
-
This is the working code: game.module('game.main').require('game.assets').body(function() {game.createScene('Main', { backgroundColor: 0x000000, init: function() { this.terrain = new game.Sprite("world/terrain.png"); this.terrain.position.set(0, game.system.height - this.terrain.height); this.terrain.interactive = true; this.stage.addChild(this.terrain); this.terrain.touchstart = this.terrain.click = function(){ game.system.setScene("Game"); } },});game.createScene('Game', { backgroundColor: 0x000000, birdsArray: [], init: function(){ /* WORLD & CONTAINERS */ this.world = new game.World(0, 9); this.world.ratio = 1; /* CONTAINER */ this.bgContainer = new game.Container(); this.bgContainer.addTo(this.stage); this.topBar = new game.Container(); this.topBar.addTo(this.stage); /* CLOUDS */ this.addParallax(0, 'world/clouds.png', -35); /* ADD BG IMAGES AND WORLD IMAGES */ this.citybg = new game.Sprite("world/backCity.png"); this.addParallax(game.system.height - this.citybg.height, 'world/backCity.png', 5); this.terrain = new game.Sprite("world/terrain.png"); this.addParallax(game.system.height - this.terrain.height, 'world/terrain.png', 25); /* TUBES SPAWN */ this.birdsGenerator(); }, birdsGenerator: function() { console.log('spawn'); this.addTimer(1000, this.birdsGenerator.bind(this)); }, addParallax: function(y, path, speed) { var parallax = new game.TilingSprite(path); parallax.position.y = y; parallax.speed.x = speed; parallax.addTo(this.bgContainer); this.addObject(parallax); } });});but if in the main scene I change the init function simply with: init: function() { game.system.setScene("Game"); },the game scene doesn't work properly, for example the function parallax is not working as expected (no movement).