Skip to content

Commit 67f24ea

Browse files
committed
SpineGameObject.willRender is no longer hard-coded to return true. It instead now takes a Camera parameter and performs all of the checks needed before returning. Previously, this happened during the render functions.
1 parent d35ff33 commit 67f24ea

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

plugins/spine/src/gameobject/SpineGameObject.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,17 +242,27 @@ var SpineGameObject = new Class({
242242
},
243243

244244
/**
245-
* Overrides the default Game Object method and always returns true.
246-
* Rendering is decided in the renderer functions.
245+
* Returns `true` if this Spine Game Object both has a skeleton and
246+
* also passes the render tests for the given Camera.
247247
*
248248
* @method SpineGameObject#willRender
249249
* @since 3.19.0
250250
*
251-
* @return {boolean} Always returns `true`.
251+
* @return {boolean} `true` if this Game Object should be rendered, otherwise `false`.
252252
*/
253-
willRender: function ()
253+
willRender: function (camera)
254254
{
255-
return true;
255+
var skeleton = this.skeleton;
256+
257+
if (!skeleton)
258+
{
259+
return false;
260+
}
261+
262+
var GameObjectRenderMask = 15;
263+
var childAlpha = skeleton.color.a;
264+
265+
return !(GameObjectRenderMask !== this.renderFlags || (this.cameraFilter !== 0 && (this.cameraFilter & camera.id)) || childAlpha === 0);
256266
},
257267

258268
/**

0 commit comments

Comments
 (0)