Skip to main content
added 85 characters in body
Source Link
jhocking
  • 15.8k
  • 2
  • 45
  • 59

aha I see in your posted code that you created LampPost as a literal object, and not as an object to instantiate. So you'll do something like:

LampPost = function(x,y) {
  this.x = x;
  this.y = y;
  blah blah
}

LampPost.prototype.draw = function() {
  ctxPropsOver.translate(this.x, this.y);
  blah blah
}

var post = new LampPost(100, 0);
post.draw();

I suggest looking up JavaScript OOP, possibly by doing lessons on CodeAcademy

aha I see in your posted code that you created LampPost as a literal object, and not as an object to instantiate. So you'll do something like:

LampPost = function(x,y) {
  blah blah
}

LampPost.prototype.draw = function() {
  blah blah
}

var post = new LampPost(100, 0);
post.draw();

I suggest looking up JavaScript OOP, possibly by doing lessons on CodeAcademy

aha I see in your posted code that you created LampPost as a literal object, and not as an object to instantiate. So you'll do something like:

LampPost = function(x,y) {
  this.x = x;
  this.y = y;
  blah blah
}

LampPost.prototype.draw = function() {
  ctxPropsOver.translate(this.x, this.y);
  blah blah
}

var post = new LampPost(100, 0);
post.draw();

I suggest looking up JavaScript OOP, possibly by doing lessons on CodeAcademy

deleted 263 characters in body
Source Link
jhocking
  • 15.8k
  • 2
  • 45
  • 59

Write a function createLampPost(x,y) that is a wrapper for the full creation method and that returns the created object:

createLampPost = function(x,y) {
  return new Thing("lamp.png", "big", x, y);
}

Then

var post = createLampPost(100,0);

ADDITION: ooohaha I see in your posted code that you created LampPost as a literal object, and not as an object to instantiate. So you'll do something like:

LampPost = function(x,y) {
  blah blah
}

LampPost.prototype.draw = function() {
  blah blah
}

var post = new LampPost(100, 0);
post.draw();

I suggest looking up JavaScript OOP, possibly by doing lessons on CodeAcademy

Write a function createLampPost(x,y) that is a wrapper for the full creation method and that returns the created object:

createLampPost = function(x,y) {
  return new Thing("lamp.png", "big", x, y);
}

Then

var post = createLampPost(100,0);

ADDITION: oooh I see in your posted code that you created LampPost as a literal object, and not as an object to instantiate. So you'll do something like:

LampPost = function(x,y) {
  blah blah
}

LampPost.prototype.draw = function() {
  blah blah
}

var post = new LampPost(100, 0);

I suggest looking up JavaScript OOP, possibly by doing lessons on CodeAcademy

aha I see in your posted code that you created LampPost as a literal object, and not as an object to instantiate. So you'll do something like:

LampPost = function(x,y) {
  blah blah
}

LampPost.prototype.draw = function() {
  blah blah
}

var post = new LampPost(100, 0);
post.draw();

I suggest looking up JavaScript OOP, possibly by doing lessons on CodeAcademy

Source Link
jhocking
  • 15.8k
  • 2
  • 45
  • 59

Write a function createLampPost(x,y) that is a wrapper for the full creation method and that returns the created object:

createLampPost = function(x,y) {
  return new Thing("lamp.png", "big", x, y);
}

Then

var post = createLampPost(100,0);

ADDITION: oooh I see in your posted code that you created LampPost as a literal object, and not as an object to instantiate. So you'll do something like:

LampPost = function(x,y) {
  blah blah
}

LampPost.prototype.draw = function() {
  blah blah
}

var post = new LampPost(100, 0);

I suggest looking up JavaScript OOP, possibly by doing lessons on CodeAcademy