phaser/v3/src/gameobjects/sprite/SpriteCanvasRenderer.js

30 lines
776 B
JavaScript
Raw Normal View History

2017-01-24 18:08:56 +00:00
var SpriteCanvasRenderer = function (renderer, src, interpolationPercentage)
{
var frame = src.frame;
var alpha = src.color.worldAlpha * 255 << 24;
// Skip rendering?
if (src.skipRender || !src.visible || alpha === 0 || !frame.cutWidth || !frame.cutHeight)
{
return;
}
var data = src.transform.getCanvasTransformData(interpolationPercentage, renderer);
var tint = src.color._glTint;
var bg = src.color._glBg;
renderer.drawImage(frame, src.blendMode, data, alpha, tint, bg);
// Render children
for (var i = 0; i < src.children.list.length; i++)
{
var child = src.children.list[i];
child.renderCanvas(renderer, child, interpolationPercentage);
}
};
module.exports = SpriteCanvasRenderer;