Class cc.ProgressTimer
- Defined in: CCProgressTimer.js
- Extends cc.NodeRGBA
Constructor Attributes | Constructor Name and Description |
---|---|
cc.Progresstimer is a subclass of cc.Node.
|
Method Summary
Class Detail
It renders the inner sprite according to the percentage.
The progress can be Radial, Horizontal or vertical.
Field Detail
- Midpoint is used to modify the progress start position.
If you're using radials type then the midpoint changes the center point
If you're using bar type the the midpoint changes the bar growth
it expands from the center but clamps to the sprites edge so:
you want a left to right then set the midpoint all the way to cc.p(0,y)
you want a right to left then set the midpoint all the way to cc.p(1,y)
you want a bottom to top then set the midpoint all the way to cc.p(x,0)
you want a top to bottom then set the midpoint all the way to cc.p(x,1)
Method Detail
-
create a progress timer object with image file name that renders the inner sprite according to the percentage
// Example var progress = cc.ProgressTimer.create('progress.png')
- Parameters:
- {cc.Sprite} sprite
- Returns:
- {cc.ProgressTimer}
-
draw(ctx)Stuff gets drawn here
- Parameters:
- {CanvasRenderingContext2D} ctx
-
{cc.Point} getBarChangeRate()This allows the bar type to move the component at a specific rate Set the component to 0 to make sure it stays at 100%. For example you want a left to right bar but not have the height stay 100% Set the rate to be cc.p(0,1); and set the midpoint to = cc.p(0,.5f);
- Returns:
- {cc.Point}
-
{cc.Color} getColor()return color of sprite
- Returns:
- {cc.Color}
-
{cc.Point} getMidpoint()Midpoint is used to modify the progress start position. If you're using radials type then the midpoint changes the center point If you're using bar type the the midpoint changes the bar growth it expands from the center but clamps to the sprites edge so: you want a left to right then set the midpoint all the way to cc.p(0,y) you want a right to left then set the midpoint all the way to cc.p(1,y) you want a bottom to top then set the midpoint all the way to cc.p(x,0) you want a top to bottom then set the midpoint all the way to cc.p(x,1)
- Returns:
- {cc.Point}
-
{Number} getOpacity()return Opacity of sprite
- Returns:
- {Number}
-
{Number} getPercentage()Percentages are from 0 to 100
- Returns:
- {Number}
-
{cc.Sprite} getSprite()The image to show the progress percentage, retain
- Returns:
- {cc.Sprite}
-
Change the percentage to change progress
-
{Boolean} initWithSprite(sprite)Initializes a progress timer with the sprite as the shape the timer goes through
- Parameters:
- {cc.Sprite} sprite
- Returns:
- {Boolean}
-
setBarChangeRate(barChangeRate)
- Parameters:
- {cc.Point} barChangeRate
-
setColor(color)set color of sprite
- Parameters:
- {cc.Color} color
-
setMidpoint(mpoint)Midpoint setter
- Parameters:
- {cc.Point} mpoint
-
setOpacity(opacity)Opacity
- Parameters:
- {Number} opacity
-
setPercentage(percentage)from 0-100
- Parameters:
- {Number} percentage
-
setReverseDirection(reverse)Reverse Progress setter
- Parameters:
- {Boolean} reverse
-
setReverseProgress(reverse)
- Parameters:
- {Boolean} reverse
-
setSprite(sprite)
- Parameters:
- {cc.Sprite} sprite
-
setType(type)set Progress type of cc.ProgressTimer
- Parameters:
- {cc.PROGRESS_TIMER_TYPE_RADIAL|cc.PROGRESS_TIMER_TYPE_BAR} type