cykod / Quintus

HTML5 Game Engine
http://html5quintus.com
GNU General Public License v2.0
1.41k stars 401 forks source link

Cannot read property 'rate' of undefined #16

Closed alessiodallapiazza closed 11 years ago

alessiodallapiazza commented 11 years ago

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: sprites The json player: "player": { "tilew": 30, "tileh": 30, "sx":0, "sy": 0, "w": 90, "h": 28 },

Thank you !

cykod commented 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' ?

alessiodallapiazza commented 11 years ago

the sprite code is really simple:

http://pastebin.com/7JmJFiLW

Thank you !

gvhuyssteen commented 11 years ago

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

alessiodallapiazza commented 11 years ago

Many thanks, now work fine !

Good evening && work :D