@@ -59,6 +59,8 @@ sp.ATTACHMENT_TYPE = {
59
59
SKINNED_MESH :3
60
60
} ;
61
61
62
+ var spine = sp . spine ;
63
+
62
64
/**
63
65
* <p>
64
66
* The skeleton of Spine. <br/>
@@ -78,7 +80,6 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
78
80
_premultipliedAlpha : false ,
79
81
_ownsSkeletonData : null ,
80
82
_atlas : null ,
81
- _blendFunc : null ,
82
83
83
84
/**
84
85
* 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# */{
105
106
init : function ( ) {
106
107
cc . Node . prototype . init . call ( this ) ;
107
108
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 } ;
109
109
this . scheduleUpdate ( ) ;
110
110
} ,
111
111
@@ -171,7 +171,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
171
171
172
172
/**
173
173
* Initializes sp.Skeleton with Data.
174
- * @param {spine.SkeletonData|String } skeletonDataFile
174
+ * @param {sp. spine.SkeletonData|String } skeletonDataFile
175
175
* @param {String|spine.Atlas|spine.SkeletonData } atlasFile atlas filename or atlas data or owns SkeletonData
176
176
* @param {Number } [scale] scale can be specified on the JSON or binary loader which will scale the bone positions, image sizes, and animation translations.
177
177
*/
@@ -211,13 +211,13 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
211
211
*/
212
212
getBoundingBox : function ( ) {
213
213
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 ,
215
215
slots = this . _skeleton . slots , VERTEX = spine . RegionAttachment ;
216
216
217
217
for ( var i = 0 , slotCount = slots . length ; i < slotCount ; ++ i ) {
218
218
var slot = slots [ i ] ;
219
219
var attachment = slot . attachment ;
220
- if ( ! attachment || ! ( attachment instanceof spine . RegionAttachment ) )
220
+ if ( ! attachment || ! ( attachment instanceof spine . RegionAttachment ) )
221
221
continue ;
222
222
vertices = attachment . updateWorldVertices ( slot , false ) ;
223
223
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# */{
260
260
/**
261
261
* Finds a bone by name. This does a string comparison for every bone.
262
262
* @param {String } boneName
263
- * @returns {spine.Bone }
263
+ * @returns {sp. spine.Bone }
264
264
*/
265
265
findBone : function ( boneName ) {
266
266
return this . _skeleton . findBone ( boneName ) ;
@@ -269,7 +269,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
269
269
/**
270
270
* Finds a slot by name. This does a string comparison for every slot.
271
271
* @param {String } slotName
272
- * @returns {spine.Slot }
272
+ * @returns {sp. spine.Slot }
273
273
*/
274
274
findSlot : function ( slotName ) {
275
275
return this . _skeleton . findSlot ( slotName ) ;
@@ -278,7 +278,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
278
278
/**
279
279
* 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.
280
280
* @param {string } skinName
281
- * @returns {spine.Skin }
281
+ * @returns {sp. spine.Skin }
282
282
*/
283
283
setSkin : function ( skinName ) {
284
284
return this . _skeleton . setSkinByName ( skinName ) ;
@@ -288,7 +288,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
288
288
* Returns the attachment for the slot and attachment name. The skeleton looks first in its skin, then in the skeleton data’s default skin.
289
289
* @param {String } slotName
290
290
* @param {String } attachmentName
291
- * @returns {spine.RegionAttachment| spine.BoundingBoxAttachment }
291
+ * @returns {sp. spine.Attachment }
292
292
*/
293
293
getAttachment : function ( slotName , attachmentName ) {
294
294
return this . _skeleton . getAttachmentByName ( slotName , attachmentName ) ;
@@ -321,8 +321,8 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
321
321
322
322
/**
323
323
* 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
326
326
*/
327
327
setSkeletonData : function ( skeletonData , ownsSkeletonData ) {
328
328
if ( skeletonData . width != null && skeletonData . height != null )
@@ -338,8 +338,8 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
338
338
339
339
/**
340
340
* 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 }
343
343
*/
344
344
getTextureAtlas : function ( regionAttachment ) {
345
345
return regionAttachment . region ;
@@ -350,23 +350,23 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
350
350
* @returns {cc.BlendFunc }
351
351
*/
352
352
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
+ }
354
361
} ,
355
362
356
363
/**
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 .
358
365
* @param {cc.BlendFunc|Number } src
359
366
* @param {Number } [dst]
360
367
*/
361
368
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 ;
370
370
} ,
371
371
372
372
/**
@@ -378,6 +378,14 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{
378
378
}
379
379
} ) ;
380
380
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
+
381
389
/**
382
390
* Creates a skeleton object.
383
391
* @deprecated since v3.0, please use new sp.Skeleton(skeletonDataFile, atlasFile, scale) instead.
0 commit comments