mirror of
https://github.com/photonstorm/phaser
synced 2024-12-24 20:13:35 +00:00
30 lines
776 B
JavaScript
30 lines
776 B
JavaScript
|
|
||
|
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;
|