Apathy Posted March 23, 2014 Share Posted March 23, 2014 I started playing with the pandajs library only yesterday so maybe it is some really small problem. But i would like some help. I create a scene, and 2 objects of class Bubble I created on it. The init function of these object gets called but not the update function as shown by the console.log lines I put on the 2 functions. Anyway here is the code.game.module('game.main').require('engine.core').body(function(){ game.addAsset('media/Background1.png','Background');game.addAsset('media/Menu/Menu2.png','Menu');game.addAsset('media/Player/Bubblo0001.png','Bubble1');game.addAsset('media/Player/Bubblo0002.png','Bubble2');game.addAsset('media/Player/Bubblo0003.png','Bubble3');game.addAsset('media/Player/Bubblo0004.png','Bubble4');game.addAsset('media/Player/Bubblo0005.png','Bubble5');game.addAsset('media/Player/Bubblo0006.png','Bubble6');game.addAsset('media/Player/Bubblo0007.png','Bubble7');game.addAsset('media/Player/Bubblo0008.png','Bubble8');game.addAsset('media/Player/Bubblo0009.png','Bubble9');game.addAsset('media/Player/Bubblo0010.png','Bubble10');game.System.orientation = game.System.LANDSCAPE;Bubble= game.Class.extend({ anima: new Array(), cont: 0, con: 0, sprite: null, init: function( x,y,cont, scale ){ this.cont=cont; this.anima.push('Bubble1'); this.anima.push('Bubble2'); this.anima.push('Bubble3'); this.anima.push('Bubble4'); this.anima.push('Bubble5'); this.anima.push('Bubble6'); this.anima.push('Bubble7'); this.anima.push('Bubble8'); this.anima.push('Bubble9'); this.anima.push('Bubble10'); this.sprite=new game.Sprite(this.anima[this.cont-1]); this.sprite.anchor.x=0.5; this.sprite.anchor.y=0.5; this.sprite.position.x=x; this.sprite.position.y=y; this.sprite.scale.x=scale; this.sprite.scale.y=scale; game.scene.stage.addChild(this.sprite); game.scene.addObject(this); console.log('BUT'); }, update: function(){ console.log('WHYYYYYY'); }}); SceneGame = game.Scene.extend({con: 0,spriteMenu: null,scx: 0,bub1: null,bub2: null,init: function() {this.scx=game.system.width/800; var spriteBackground = new game.Sprite('Background');this.stage.addChild(spriteBackground);spriteBackground.anchor.x=0;spriteBackground.anchor.y=0;spriteBackground.position.x=0;spriteBackground.position.y=0;spriteBackground.scale.x=this.scx;spriteBackground.scale.y=game.system.height/480;this.spriteMenu = new game.Sprite('Menu');this.stage.addChild(this.spriteMenu);this.spriteMenu.anchor.x=0.5;this.spriteMenu.anchor.y=0.5;// Tween sprite positionthis.spriteMenu.position.x=game.system.width/2;this.spriteMenu.position.y=game.system.height/2;this.spriteMenu.scale.x=0.1*this.scx;this.spriteMenu.scale.y=0.1*this.scx;},click:function(event){ },update: function(){ if(this.con<9){ this.con+=1; this.spriteMenu.scale.x+=0.1*this.scx; this.spriteMenu.scale.y+=0.1*this.scx; if(this.con==9){ this.bub1=new Bubble(238*this.scx,352*this.scx,9,1.2*this.scx); this.bub2=new Bubble(399*this.scx,347*this.scx,9,1.6*this.scx); } }}}); game.start(SceneGame); });Hope to solve it. Really like this engine. Keep up the good work to the creator and contributors. Quote Link to comment Share on other sites More sharing options...
enpu Posted March 23, 2014 Share Posted March 23, 2014 You are right, it's small problem. You need to add your object to scene's object list, to get it's update function called every frame. Example:var bubble = new Bubble();this.addObject(bubble); Quote Link to comment Share on other sites More sharing options...
Apathy Posted March 23, 2014 Author Share Posted March 23, 2014 Thanks for the fast reply. But I have used in the bubble init function the game.scene.addObject(this); to do that. I also tried the way you suggested but its the same result. Quote Link to comment Share on other sites More sharing options...
enpu Posted March 24, 2014 Share Posted March 24, 2014 Ah, that is because you are overwriting scene's update function. Try:update: function() { this._super(); // Your code} Quote Link to comment Share on other sites More sharing options...
Apathy Posted March 24, 2014 Author Share Posted March 24, 2014 Thanks a lot! This solved it! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.