Home > other >  Cocos lua circle mask tailor
Cocos lua circle mask tailor

Time:09-23


Use cocos2d should know ClippingNode and ProgressTimer use method, the realization of the function of this is based on their implementation,
Demand (topic ideas) : a complete circular frame animation (not picture) to cut it, cut through ProgressTimer control area control frame animation viewing area, join the timer can realize the visualization of the effect of slow growth,
Note: if this is a picture directly through ProgressTimer percentage can display progress bar
great god don't gush!!!!!!!!!! Code on the
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- there should be a picture here, -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
image upload will not come!!!!!!!!!!

 
The local Sprite=cc. Sprite: create (" xx. PNG ") - a picture of a ring shape
The local progress=cc. ProgressTimer: create (Sprite) - create ProgressTimer
Progress: setPercentage (0) -
Progress: elegantly-named setName (" per ")

The local holesStencil=cc. Node: the create ()
HolesStencil: elegantly-named setName (" holesStencil ")
HolesStencil: addChild (progress)
Local spriteBg=cc. Sprite: create (" xx. PNG ") - background can be used to place the frame animation and top with a picture

SpriteBg: elegantly-named setName (" spriteBg ")
SpriteBg: setOpacity (0)

The local eff=XXX -- -- -- -- --
frame animationSpriteBg: addChild (eff)
Local clipS=cc. ClippingNode: the create () - create ClippingNode
ClipS: setStencil (holesStencil)
ClipS: addChild (spriteBg)
ClipS: elegantly-named setName (" clipS ")


ClipS: setInverted (false) - sets the visual area of cutting area, or cut the remaining area
ClipS: setAlphaThreshold (1) - according to alpha value control
ClipS: setAnchorPoint (cc) p (0, 0))
Node: addChild (clipS) - added to the Node


============================================
-
The local nodeClip=Node: getChildByName (" clipS ")
The local nodeStencil=nodeClip: getStencil ()
The local nodeProgess=nodeStencil: getChildByName (" per ")
-- -- -- -- -- by setting the ProgressTimer control display area
NodeProgess: setPercentage (xx)

Position placement and alignment needs to be adjusted according to your actual demand
Cutting principle may refer to the following content, there is not much said
http://www.mamicode.com/info-detail-247772.html

CodePudding user response:

So do you want to ask?

CodePudding user response:

reference 1st floor u013962723 response:
so what do you want to ask?


What also don't ask, don't share
  • Related