读书人

ios cocos2d兑现progress(进度条)效果

发布时间: 2013-03-01 18:33:02 作者: rapoo

ios cocos2d实现progress(进度条)效果控件源码

这半年一直在用object-c开发一个ios游戏。使用cocos2d和box2d 。开发游戏变的简单多了。这游戏开发了半年多了。直到最近这个游戏停止了,因为资金问题,老大没法在发更多的工资了。哎,真的非常遗憾,我一个人完成游戏的编辑器开发,脚本开发,游戏代码开发,很不容易,因为我学object-c,coco2d才看了2个星期的书就直接开发了,以前是搞c++的吗。感觉4个人开发游戏真的很累,游戏为了脱颖出更加真实的效果还使用了物理引擎,在老大的同意的情况下,我共享cocos2d自己写的一些大家比较常用的,因为cocos2d有些控件不怎么好用或者没有,反正我觉得是这样的。如slider(滑块),button(按钮),RollNumber(数字滚动),Progress(进度条)....控件一一在我的博客里面公布,可以直接使用.源码打包下载

开发人员:Jason's.Alex QQ:531401335

csdn博客:http://blog.csdn.net/RuShrooM


//

////  CCProgressTimerEffect.m//  DiceGameBox2D////  Created by jasonsalex on 13-1-27.////#import "CCProgressTimerEffect.h"#import "ResourceLoad.h"@implementation CCProgressTimerEffect@synthesize maxValue;+(id)progressTimerWithEffect:(float)max_value background:(id)bg frontground:(id)fg{    return [[[self alloc]initWithProgressTimerEffect:max_value background:bg frontground:fg]autorelease];}-(id)initWithProgressTimerEffect:(float)max_value background:(id)bg frontground:(id)fg{    if(self=[super initWithFile:fg]);    {        maxValue=max_value;        bgSprite=[CCSprite spriteWithFile:bg rect:[self boundingBox]];                id strValue=[NSString stringWithFormat:@"0/%i",(int)maxValue];                valueTTF=[CCLabelTTF labelWithString:strValue fontName:DefaultFontName fontSize:DefaultFontSize];        CGSize size=[self boundingBox].size;                size.width*=0.5f;        size.height*=0.5f;                [valueTTF setPosition:ccp(size.width,size.height)];        [bgSprite setPosition:[valueTTF position]];                [self addChild:valueTTF];        [self addChild:bgSprite z:-1];            }        return self;}-(void)dealloc{    NSLog(@"~ProgressTimer");    [super dealloc];}-(void)setPercentage:(float)percentage{    curValue=percentage;        id str=[NSString stringWithFormat:@"%i/%i",(int)curValue,(int)maxValue];    [valueTTF setString:str];        [super setPercentage:curValue/maxValue*100.0f];}@end


读书人网 >操作系统

热点推荐