Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot read property 'x' of undefined #646

Closed
autergame opened this issue Aug 16, 2018 · 1 comment
Closed

Uncaught TypeError: Cannot read property 'x' of undefined #646

autergame opened this issue Aug 16, 2018 · 1 comment
Labels

Comments

@autergame
Copy link

autergame commented Aug 16, 2018

i am new in this forum

var boundariesg = [];
boundariesg.push(new Boundary(mouseX, mouseY, 200, 20, anglee / PI));
Body.setPosition(boundariesg[1], { x: mouseX, y: mouseY });

---boundarie code---

function Boundary(x, y, w, h, a) {
  var options = {
    friction: 0,
    restitution: 0.90,
    angle: a,
    isStatic: true
  }
  this.body = Bodies.rectangle(x, y, w, h, options);
  this.w = w;
  this.h = h;
  World.add(world, this.body);

  this.removeFromWorld = function() {
    World.remove(world, this.body);
  }

  this.show = function() {
    var pos = this.body.position;
    var angle = this.body.angle;
    push();
    translate(pos.x, pos.y);
    rotate(angle);
    rectMode(CENTER);
    strokeWeight(1);
    noStroke();
    fill(0);
    rect(0, 0, this.w, this.h);
    pop();
  }

}
@liabru
Copy link
Owner

liabru commented Aug 22, 2018

Looks like it should be Body.setPosition(boundariesg[1].body, { x: mouseX, y: mouseY });?

@liabru liabru closed this as completed Aug 22, 2018
@liabru liabru reopened this Aug 22, 2018
@autergame autergame reopened this Aug 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants