gurubw Posted May 22, 2014 Share Posted May 22, 2014 Somehow I can't get Tween to work. The rest of the code is working fine, but when using a Tween nothing happens. onStart and onComplete are not being called and there are no errors in console. Suggestions?var bottom = new game.Sprite('blacktile.png'); bottom.anchor.set(0, 1); bottom.position.set(0, game.system.height - 20); bottom.width = game.system.width / 1.5; this.stage.addChild(bottom); var tween = new game.Tween(bottom.position); tween.to({x:200},1000); tween.start(); this.textlabel = new PIXI.Text("Moves: " + this.moves, {font:"50px Arial", fill:"black"}); this.stage.addChild(this.textlabel); for(var i = 0; i <= this.board.getcolumncount(); i++) { var vert = new game.Sprite('blacktile.png'); vert.anchor.set(0,1); this.columnspace = (bottom.width - ((this.board.getcolumncount() + 1) * this.blockwidth)) / this.board.getcolumncount(); vert.position.set(i*this.blockwidth + i*this.columnspace, bottom.position.y - this.blockwidth); vert.height = this.columnspace*3+10; this.stage.addChild(vert); this.vertcolumns[this.vertcolumns.length] = vert; } this.board.initblocks(this.columnspace, this.blockwidth, bottom.position.y - this.blockwidth); var columns = this.board.getcolumns(); for(var i = 0; i < columns.length; i++) { for(var x = 0; x < columns[i].length; x++) { this.stage.addChild(columns[i][x].getsprite()); this.stage.addChild(columns[i][x].getlabel()); } } Quote Link to comment Share on other sites More sharing options...
enpu Posted May 22, 2014 Share Posted May 22, 2014 Can't see any onStart or onComplete in your code? Quote Link to comment Share on other sites More sharing options...
gurubw Posted May 22, 2014 Author Share Posted May 22, 2014 No, i deleted it after testing it, so not in the code anymore. Quote Link to comment Share on other sites More sharing options...
enpu Posted May 22, 2014 Share Posted May 22, 2014 Well then it's really hard to tell, if there was something wrong with your code. Quote Link to comment Share on other sites More sharing options...
gurubw Posted May 22, 2014 Author Share Posted May 22, 2014 Ok, changed it with onComplete and onStart and added the full scene code. Thnx for looking at it. So far, i'm pretty impressed by your panda.js project, works like a charm!SceneGame = game.Scene.extend({ backgroundColor: 0xb9bec7, board: new Board(4), moves: 0, textlabel: null, blockwidth: 32, columnspace: 0, clickA: 0, clickB: 0, clickcount: 0, vertcolumns: new Array(), init: function() { var bottom = new game.Sprite('blacktile.png'); bottom.anchor.set(0, 1); bottom.position.set(0, game.system.height - 20); bottom.width = game.system.width / 1.5; this.stage.addChild(bottom); var tween = new game.Tween(bottom.position); tween.to({x:200},1000); tween.onStart(function(){console.log('Tween started')}); tween.onComplete(function(){console.log('Tween completed')}); tween.start(); this.textlabel = new PIXI.Text("Moves: " + this.moves, {font:"50px Arial", fill:"black"}); this.stage.addChild(this.textlabel); for(var i = 0; i <= this.board.getcolumncount(); i++) { var vert = new game.Sprite('blacktile.png'); vert.anchor.set(0,1); this.columnspace = (bottom.width - ((this.board.getcolumncount() + 1) * this.blockwidth)) / this.board.getcolumncount(); vert.position.set(i*this.blockwidth + i*this.columnspace, bottom.position.y - this.blockwidth); vert.height = this.columnspace*3+10; this.stage.addChild(vert); this.vertcolumns[this.vertcolumns.length] = vert; } this.board.initblocks(this.columnspace, this.blockwidth, bottom.position.y - this.blockwidth); var columns = this.board.getcolumns(); for(var i = 0; i < columns.length; i++) { for(var x = 0; x < columns[i].length; x++) { this.stage.addChild(columns[i][x].getsprite()); this.stage.addChild(columns[i][x].getlabel()); } } }, click: function(event) { for(var i = 0; i < this.vertcolumns.length; i++) { var xStart = this.vertcolumns[i].position.x + this.blockwidth; var yStart = this.vertcolumns[i].position.y - this.vertcolumns[i].height; var xEnd = this.vertcolumns[i].position.x + this.blockwidth + this.columnspace; var yEnd = this.vertcolumns[i].position.y; if ((event.global.x > xStart) & (event.global.x < xEnd) & (event.global.y > yStart) & (event.global.y < yEnd)) { if (this.clickcount == 0) { this.clickA = i; this.clickcount++; console.log("A:" + i); } else if (this.clickcount == 1) { this.clickB = i; console.log("B:" + i); if (this.board.moveblock(this.clickA, this.clickB)) this.moves++; this.clickcount = 0; } console.log("count:" + this.clickcount); } } }, update:function() { this.textlabel.setText("Moves: " + this.moves); var columns = this.board.getcolumns(); for(var i = 0; i < columns.length; i++) { for(var x = 0; x < columns[i].length; x++) { columns[i][x].getsprite(); columns[i][x].getlabel(); } } }}); Quote Link to comment Share on other sites More sharing options...
enpu Posted May 22, 2014 Share Posted May 22, 2014 You are overwriting game.Scene original update function. add this._super(); to your update function. Quote Link to comment Share on other sites More sharing options...
gurubw Posted May 22, 2014 Author Share Posted May 22, 2014 Oopss.. Should have looked further. Thanks a lot! Quote Link to comment Share on other sites More sharing options...
gurubw Posted June 2, 2014 Author Share Posted June 2, 2014 Would it be possible to communicate between scenes? For instance: call a variable in one scene from the other? Quote Link to comment Share on other sites More sharing options...
enpu Posted June 2, 2014 Share Posted June 2, 2014 Hmm no. But you can make global variables, like: game.currentLevel = 1; Quote Link to comment Share on other sites More sharing options...
gurubw Posted June 2, 2014 Author Share Posted June 2, 2014 Ok, thnx. I'll work it out with globals 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.