Closed alessiodallapiazza closed 11 years ago
Need to get better error messages in anim - did you add a 'sprite' property to the player and set it to 'player' ?
Q.Sprite.extend("Player",{ init: function(p) { this._super(p, { sheet: "player", // Setting a sprite sheet sets sprite width and height x: 410, // You can also set additional properties that can y: 90 // be overridden on object creation });
add a sprite to your extended player like below
Q.Sprite.extend("Player",{ init: function(p) { this._super(p, { sheet: "player", // Setting a sprite sheet sets sprite width and height sprite: "player", x: 410, // You can also set additional properties that can y: 90 // be overridden on object creation });
I had the same problem yesterday. I agree, it needs more precise error messages
Many thanks, now work fine !
Good evening && work :D
Hi, i'm working with animation..
I have added to code "plataformer" this:
Q.animations('player', { left: { frames: [0,2], rate:1/2}, right: { frames: [0,1], rate:1/2}, stand: { frames: [0,0], rate:1/2} });
I have added animation on player: this.add('2d, platformerControls, animation');
I have added function: step: function(dt) { if(this.p.vx > 0) { this.play("right"); } else if(this.p.vx < 0) { this.play("left"); } else { this.play("stand"); } }
And i have this error: Cannot read property 'rate' of undefined
The images used in animation are: The json player: "player": { "tilew": 30, "tileh": 30, "sx":0, "sy": 0, "w": 90, "h": 28 },
Thank you !