Class cc.ProgressTimer

Class Summary
Constructor Attributes Constructor Name and Description
 
cc.Progresstimer is a subclass of cc.Node.

Method Summary

Class Detail

cc.ProgressTimer()
cc.Progresstimer is a subclass of cc.Node.
It renders the inner sprite according to the percentage.
The progress can be Radial, Horizontal or vertical.

Field Detail

{cc.Point} barChangeRate
- This allows the bar type to move the component at a specific rate.
{cc.Point} midPoint

- 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)

{Number} percentage
- Percentage to change progress, from 0 to 100.
{Boolean} reverseDir
- Indicate whether the direction is reversed.
{cc.Sprite} sprite
- The sprite to show the progress percentage.
{enum} type
- Type of the progress timer: cc.PROGRESS_TIMER_TYPE_RADIAL|cc.PROGRESS_TIMER_TYPE_BAR.

Method Detail

  • <static> {cc.ProgressTimer} cc.ProgressTimer.create(sprite)
    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
    Returns:
    {cc.PROGRESS_TIMER_TYPE_RADIAL|cc.PROGRESS_TIMER_TYPE_BAR}
  • {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