![]() |
Problem with Object Function
Here's my code, the problem is when ever I try using an object's (obj_player) step or draw functions. The creation of the object runs fine, I get no errors until I try placing the step and draw functions in.
The problem's are bolded so you won't have to bother with my code. Also If you take a look at my way of loaded images and give advice there it be much appreciated. Code:
// after page has loaded execute codeThanks for your help, Cay |
What is the error you get?
Where are the definitions of the (supposedly global) variables gravity, height, width, image_index and sprite? |
The error isn't defined, the page simply doesn't finish compiling the code when I put
obj_player.step() or obj_player.draw() inside the system functions. I fixed it right now though., looking back at my code. It seems I forgot to add a "this" statement infront of a variable Thanks devnull! I have new question , still in relation to objects so I'll continue it here. So, I got the drawing script to work : Code:
this.draw = function()Code:
this.floor = 0;Code:
ctx.drawImage( this.sprite[ this.state ] , this.x, this.y); |
In order to access a key/value pair out of an object literal with a dynamically generated key you'll have to specify the key (not an index) as a string. Try this
Code:
this.floor = "spr_stand"; |
Thank's so much devnull!
|
| All times are GMT +1. The time now is 08:48 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.