| 334 | } |
| 335 | |
| 336 | preDraw(renderer) { |
| 337 | renderer.save(); |
| 338 | |
| 339 | // translate to the entity position |
| 340 | renderer.translate( |
| 341 | this.pos.x + this.body.getBounds().x, |
| 342 | this.pos.y + this.body.getBounds().y, |
| 343 | ); |
| 344 | |
| 345 | if (this.renderable instanceof Renderable) { |
| 346 | // draw the child renderable's anchorPoint at the entity's |
| 347 | // anchor point. the entity's anchor point is a scale from |
| 348 | // body position to body width/height |
| 349 | renderer.translate( |
| 350 | this.anchorPoint.x * this.body.getBounds().width, |
| 351 | this.anchorPoint.y * this.body.getBounds().height, |
| 352 | ); |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | /** |
| 357 | * draw this entity (automatically called by melonJS) |