LinkTree Posted April 25, 2015 Share Posted April 25, 2015 Hi, I tried to tween a sprite inside a new class but I keep getting this error and I am not sure what's causing it:uncaught exception: Tween parameter must be object I checked if the parameter I provide to Tween is an object and it is. I don't understand why it activates thisif (typeof object !== 'object') throw('Tween parameter must be object'); in the Tween init function.game.createClass("Panda",{ init: function(){ this.sprite = new game.Sprite("panda.png", 100, 50); this.sprite.anchor.set(0.5, 0.5); game.scene.stage.addChild(this.sprite); //Now add some tweens... var tween1 = new game.Tween(this.sprite.position); tween1.delay(1000); tween1.to({x:200}, 1000); tween1.easing(game.Tween.Easing.Quadratic.InOut); tween1.onComplete(function(){ console.log("spawn new panda"); var panda = new game.Panda(); }); var tween2 = new game.Tween(this.sprite.position); tween2.easing(game.Tween.Easing.Bounce.Out); tween2.to({y:200}, 1000); var tween3 = new game.Tween(this.position); //Note that x is the movement from to the starting position of x before ALL tweens were started!! tween3.to({x:500}, 1500); //Notice the difference between the method we user here and on tween1. //In this case we linked the callback function directly. tween3.onCompleteCallback = function(){ this.sprite.remove(); }.bind(this); var tween4 = new game.Tween(this.sprite); //Note that x is the movement from to the starting position of x before ALL tweens were started!! tween4.to({rotation:2*Math.PI}, 1500); //chain the whole lot and get started tween1.chain(tween2); tween2.chain(tween3, tween4); tween1.start(); }, remove: function(){ //kill this fellow! game.scene.stage.removeChild(this); } });also I noticed that in the particle emitter if I set the emitter spriteSettings to blend mode add like this:emitter.spriteSettings = {blendMode: game.PIXI.blendModes.ADD}the image is very dirty and pixelated and shows a lot of artifacts. I don't know what's causing this. Quote Link to comment Share on other sites More sharing options...
jpdev Posted April 25, 2015 Share Posted April 25, 2015 With just glancing over the code, maybe it's tween3?All other tweens are started on this.sprite.position, with tween3 you go for this.position. Quote Link to comment Share on other sites More sharing options...
LinkTree Posted April 25, 2015 Author Share Posted April 25, 2015 With just glancing over the code, maybe it's tween3?All other tweens are started on this.sprite.position, with tween3 you go for this.position.thank you! that was actually the problem! do you happen to know what is causing the second issue with the emitter texture blendmode? Quote Link to comment Share on other sites More sharing options...
jpdev Posted April 25, 2015 Share Posted April 25, 2015 No sorry, I don't have any know-how when it comes to the blend modes.Glad I could help with the tween Maybe somebody else knows what's up with the emitter. Quote Link to comment Share on other sites More sharing options...
SkyzohKey Posted April 25, 2015 Share Posted April 25, 2015 I guess the problem is that you give the position as object, try directly with the sprite, like that: var tween1 = new game.Tween(this.sprite); Quote Link to comment Share on other sites More sharing options...
LinkTree Posted April 25, 2015 Author Share Posted April 25, 2015 I guess the problem is that you give the position as object, try directly with the sprite, like that: var tween1 = new game.Tween(this.sprite);thank you for your replay. the first issue was solved but I am still having an issue with the emitter blendmode producing very pixelated textures. also when you group multiple tweens they lose their individual onComplete(callback) functions. I tried to console.log text when 1 tween out of a group finishes and it doesn't do anything. if I try to do tween.onComplete = function() it calls the function but it doesn't run on the tween's animation completion but rather on the tween instantiation. the documentation is very lacking in this area. 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.