Skip to content

Instantly share code, notes, and snippets.

@wonkwh
Created November 29, 2012 13:28
Show Gist options
  • Save wonkwh/4169067 to your computer and use it in GitHub Desktop.
Save wonkwh/4169067 to your computer and use it in GitHub Desktop.
cocos2d-android:using CCProgressTimer
/**
* User: kwanghyun
* Date: 12. 11. 28
* Time: 오후 6:10
*/
public class ProgressSprite extends CCProgressTimer
{
private static final String TAG = "ProgressSprite";
private GameLayer game_layer_ = null;
private float progress_rate_;
public ProgressSprite(GameLayer game_layer)
{
super("timeslider_progress_bar.png");
this.game_layer_ = game_layer;
this.setType(kCCProgressTimerTypeHorizontalBarLR);
}
public void run_Progress_Bar()
{
this.progress_rate_ = Game.MAX_TIME;
CGSize winSize = CCDirector.sharedDirector().winSize();
this.setPercentage(100.0f);
this.setPosition(winSize.width / 2f, 20);
this.setScale(winSize.width / this.getContentSize().width);
this.game_layer_.addChild(this,0);
schedule("update_progress", 0.1f);
}
public void update_progress(float dt)
{
Logger.d(TAG, "progress rate" + this.progress_rate_);
this.setPercentage(this.progress_rate_);
progress_rate_ -= 0.1666f;
if (this.getPercentage() <= 0.0)
{
unschedule("update_progress");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment