MCPcopy Create free account
hub / github.com/melonjs/melonJS / preDraw

Method preDraw

packages/melonjs/src/renderable/entity/entity.js:336–354  ·  view source on GitHub ↗
(renderer)

Source from the content-addressed store, hash-verified

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)

Callers 1

drawMethod · 0.45

Calls 3

getBoundsMethod · 0.65
saveMethod · 0.45
translateMethod · 0.45

Tested by

no test coverage detected