var myImage = new Image();
I initiate it like so,
myImage .src = "./png/iso_tile2.png";
myImage .thisImage = myImage ;
As seen above, I added .thisImage variable as reference to "this" so I can plug in width and height of image as member variable to this Image object.
I did that in onLoad() function,
myImage .onload = function()
{
this.width = this.naturalWidth;
this.height = this.naturalHeight;
this.x = 25;
this.y = 15;
}
As you can see, I also added x and y as new member for me to hold its position in the screen I'm drawing it. I set them to 25, 15 respectively.
But when I access them, I always get 0, 0. If i change their name to say _x, _y then it works. So I can only assume that x, y are private members of Image class?
No comments:
Post a Comment