Jump to content

Bug or?


Recommended Posts

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).

Link to comment
Share on other sites

Not entirely sure why you can't use the game.system.setScene() in init, but I think it's a known limitation. Though, if you'd like to start with a different scene, I'd suggest you use the startscene property (http://www.pandajs.net/docs/classes/game.System.html#attr_startScene) in your config.js. Using an entire scene to only initiate some variables / objects / etc... sounds like bad practice anyway.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...