@@ -59,6 +59,8 @@ sp.ATTACHMENT_TYPE = {
5959 SKINNED_MESH :3
6060} ;
6161
62+ var spine = sp . spine ;
63+
6264/**
6365 * <p>
6466 * The skeleton of Spine. <br/>
@@ -78,7 +80,6 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
7880 _premultipliedAlpha : false ,
7981 _ownsSkeletonData : null ,
8082 _atlas : null ,
81- _blendFunc : null ,
8283
8384 /**
8485 * The constructor of sp.Skeleton. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
@@ -105,7 +106,6 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
105106 init : function ( ) {
106107 cc . Node . prototype . init . call ( this ) ;
107108 this . _premultipliedAlpha = ( cc . _renderType === cc . game . RENDER_TYPE_WEBGL && cc . OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA ) ;
108- this . _blendFunc = { src : cc . BLEND_SRC , dst : cc . BLEND_DST } ;
109109 this . scheduleUpdate ( ) ;
110110 } ,
111111
@@ -171,7 +171,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
171171
172172 /**
173173 * Initializes sp.Skeleton with Data.
174- * @param {spine.SkeletonData|String } skeletonDataFile
174+ * @param {sp. spine.SkeletonData|String } skeletonDataFile
175175 * @param {String|spine.Atlas|spine.SkeletonData } atlasFile atlas filename or atlas data or owns SkeletonData
176176 * @param {Number } [scale] scale can be specified on the JSON or binary loader which will scale the bone positions, image sizes, and animation translations.
177177 */
@@ -211,13 +211,13 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
211211 */
212212 getBoundingBox : function ( ) {
213213 var minX = cc . FLT_MAX , minY = cc . FLT_MAX , maxX = cc . FLT_MIN , maxY = cc . FLT_MIN ;
214- var scaleX = this . getScaleX ( ) , scaleY = this . getScaleY ( ) , vertices = [ ] ,
214+ var scaleX = this . getScaleX ( ) , scaleY = this . getScaleY ( ) , vertices ,
215215 slots = this . _skeleton . slots , VERTEX = spine . RegionAttachment ;
216216
217217 for ( var i = 0 , slotCount = slots . length ; i < slotCount ; ++ i ) {
218218 var slot = slots [ i ] ;
219219 var attachment = slot . attachment ;
220- if ( ! attachment || ! ( attachment instanceof spine . RegionAttachment ) )
220+ if ( ! attachment || ! ( attachment instanceof spine . RegionAttachment ) )
221221 continue ;
222222 vertices = attachment . updateWorldVertices ( slot , false ) ;
223223 minX = Math . min ( minX , vertices [ VERTEX . X1 ] * scaleX , vertices [ VERTEX . X4 ] * scaleX , vertices [ VERTEX . X2 ] * scaleX , vertices [ VERTEX . X3 ] * scaleX ) ;
@@ -260,7 +260,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
260260 /**
261261 * Finds a bone by name. This does a string comparison for every bone.
262262 * @param {String } boneName
263- * @returns {spine.Bone }
263+ * @returns {sp. spine.Bone }
264264 */
265265 findBone : function ( boneName ) {
266266 return this . _skeleton . findBone ( boneName ) ;
@@ -269,7 +269,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
269269 /**
270270 * Finds a slot by name. This does a string comparison for every slot.
271271 * @param {String } slotName
272- * @returns {spine.Slot }
272+ * @returns {sp. spine.Slot }
273273 */
274274 findSlot : function ( slotName ) {
275275 return this . _skeleton . findSlot ( slotName ) ;
@@ -278,7 +278,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
278278 /**
279279 * Finds a skin by name and makes it the active skin. This does a string comparison for every skin. Note that setting the skin does not change which attachments are visible.
280280 * @param {string } skinName
281- * @returns {spine.Skin }
281+ * @returns {sp. spine.Skin }
282282 */
283283 setSkin : function ( skinName ) {
284284 return this . _skeleton . setSkinByName ( skinName ) ;
@@ -288,7 +288,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
288288 * Returns the attachment for the slot and attachment name. The skeleton looks first in its skin, then in the skeleton data’s default skin.
289289 * @param {String } slotName
290290 * @param {String } attachmentName
291- * @returns {spine.RegionAttachment| spine.BoundingBoxAttachment }
291+ * @returns {sp. spine.Attachment }
292292 */
293293 getAttachment : function ( slotName , attachmentName ) {
294294 return this . _skeleton . getAttachmentByName ( slotName , attachmentName ) ;
@@ -321,8 +321,8 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
321321
322322 /**
323323 * Sets skeleton data to sp.Skeleton.
324- * @param {spine.SkeletonData } skeletonData
325- * @param {spine.SkeletonData } ownsSkeletonData
324+ * @param {sp. spine.SkeletonData } skeletonData
325+ * @param {sp. spine.SkeletonData } ownsSkeletonData
326326 */
327327 setSkeletonData : function ( skeletonData , ownsSkeletonData ) {
328328 if ( skeletonData . width != null && skeletonData . height != null )
@@ -338,8 +338,8 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
338338
339339 /**
340340 * Return the renderer of attachment.
341- * @param {spine.RegionAttachment|spine.BoundingBoxAttachment } regionAttachment
342- * @returns {cc.Node }
341+ * @param {sp. spine.RegionAttachment|sp. spine.BoundingBoxAttachment } regionAttachment
342+ * @returns {sp.spine.TextureAtlasRegion }
343343 */
344344 getTextureAtlas : function ( regionAttachment ) {
345345 return regionAttachment . region ;
@@ -350,23 +350,23 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
350350 * @returns {cc.BlendFunc }
351351 */
352352 getBlendFunc : function ( ) {
353- return this . _blendFunc ;
353+ var slot = this . _skeleton . drawOrder [ 0 ] ;
354+ if ( slot ) {
355+ var blend = this . _renderCmd . _getBlendFunc ( slot . data . blendMode , this . _premultipliedAlpha ) ;
356+ return blend ;
357+ }
358+ else {
359+ return { } ;
360+ }
354361 } ,
355362
356363 /**
357- * Sets the blendFunc of sp.Skeleton.
364+ * Sets the blendFunc of sp.Skeleton, it won't have any effect for skeleton, skeleton is using slot's data to determine the blend function .
358365 * @param {cc.BlendFunc|Number } src
359366 * @param {Number } [dst]
360367 */
361368 setBlendFunc : function ( src , dst ) {
362- var locBlendFunc = this . _blendFunc ;
363- if ( dst === undefined ) {
364- locBlendFunc . src = src . src ;
365- locBlendFunc . dst = src . dst ;
366- } else {
367- locBlendFunc . src = src ;
368- locBlendFunc . dst = dst ;
369- }
369+ return ;
370370 } ,
371371
372372 /**
@@ -378,6 +378,14 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
378378 }
379379} ) ;
380380
381+ cc . defineGetterSetter ( sp . Skeleton . prototype , "opacityModifyRGB" , sp . Skeleton . prototype . isOpacityModifyRGB ) ;
382+
383+ // For renderer webgl to identify skeleton's default texture and blend function
384+ cc . defineGetterSetter ( sp . Skeleton . prototype , "_blendFunc" , sp . Skeleton . prototype . getBlendFunc ) ;
385+ cc . defineGetterSetter ( sp . Skeleton . prototype , '_texture' , function ( ) {
386+ return this . _renderCmd . _currTexture ;
387+ } ) ;
388+
381389/**
382390 * Creates a skeleton object.
383391 * @deprecated since v3.0, please use new sp.Skeleton(skeletonDataFile, atlasFile, scale) instead.
0 commit comments