骷髅头赛跑游戏源码


一群骷髅头在荒山上赛跑,界面通过各种特效来制造恐怖氛围,可以设置游戏参数、也可以显示排行榜
资源截图
代码片段和文件信息

#import “ColoredCircleSprite.h“

@interface ColoredCircleSprite (privateMethods)
- (void) updateContentSize;
- (void) updateColor;
@end


@implementation ColoredCircleSprite

@synthesize radius=radius_;
// Opacity and RGB color protocol
@synthesize opacity=opacity_ color=color_;
@synthesize blendFunc=blendFunc_;

+ (id) circleWithColor: (ccColor4B)color radius:(GLfloat)r
{
return [[[self alloc] initWithColor:color radius:r] autorelease];
}

- (id) initWithColor:(ccColor4B)color radius:(GLfloat)r
{
if( (self=[self init]) ) {
self.radius = r;

color_.r = color.r;
color_.g = color.g;
color_.b = color.b;
opacity_ = color.a;
}
return self;
}

- (void) dealloc
{
free(circleVertices_);
[super dealloc];
}

- (id) init
{
if((self = [super init])){
radius_ = 10.0f;
numberOfSegments = 36U;

// default blend function
blendFunc_ = (ccBlendFunc) { CC_BLEND_SRC CC_BLEND_DST };

color_.r =
color_.g =
color_.b = 0U;
opacity_ = 255U;

circleVertices_ = malloc(sizeof(GLfloat)*2*(numberOfSegments));
if(!circleVertices_){
NSLog(@“Ack!! malloc in colored circle failed“);
[self release];
return nil;
}
memset(circleVertices_ 0 sizeof(GLfloat)*2*(numberOfSegments));

self.radius = radius_;
}
return self;
}

-(void) setRadius: (float) size
{
radius_ = size;
const float theta_inc = 2.0f * 3.14159265359f/numberOfSegments;
float theta = 0.0f;

for(int i=0; i {
#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
float j = radius_ * [[CCDirector sharedDirector] contentScaleFactor] * cosf(theta) + position_.x;
float k = radius_ * [[CCDirector sharedDirector] contentScaleFactor] * sinf(theta) + position_.y;
#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
float j = radius_ * cosf(theta) + position_.x;
float k = radius_ * sinf(theta) + position_.y;
#endif

circleVertices_[i*2] = j;
circleVertices_[i*2+1] = k;

theta += theta_inc;
}

[self updateContentSize];
}

-(void) setContentSize: (CGSize) size
{
self.radius = size.width/2;
}

- (void) updateContentSize
{
[super setContentSize:CGSizeMake(radius_*2 radius_*2)];
}

- (void)draw
{
// Default GL states: GL_TEXTURE_2D GL_VERTEX_ARRAY GL_COLOR_ARRAY GL_TEXTURE_COORD_ARRAY
// Needed states: GL_VERTEX_ARRAY
// Unneeded states: GL_COLOR_ARRAY GL_TEXTURE_2D GL_TEXTURE_COORD_ARRAY
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisable(GL_TEXTURE_2D);

glVertexPointer(2 GL_FLOAT 0 circleVertices_);
glColor4f(color_.r/255.0f color_.g/255.0f color_.b/255.0f opacity_/255.0f);

BOOL newBlend = NO;
if( blendFunc_.src != CC_BLEND_SRC || blendFunc_.dst != CC_BLEND_DST ) {
newBlend = YES;
glBlendFunc(blendFunc_.src blendFunc_.dst);
}else if( opacity_ == 255 ) {
newBlend = YES;
glBlendFunc(GL_ONE GL_ZERO);
}else{
newBlend = YES;
glBlendFunc(GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA);
}

glDrawArrays(GL_TRIANGLE_FAN 0 numberOfSegments);

if( newB

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2012-11-16 16:55  Hills
     文件       21508  2012-11-16 18:03  Hills.DS_Store
     目录           0  2012-11-17 16:24  __MACOSX
     目录           0  2012-11-17 16:24  __MACOSXHills
     文件         222  2012-11-16 18:03  __MACOSXHills._.DS_Store
     目录           0  2012-11-16 16:54  HillsClasses
     文件         593  2011-09-29 16:08  HillsClassesCDynaSprite.h
     目录           0  2012-11-17 16:24  __MACOSXHillsClasses
     文件         273  2011-09-29 16:08  __MACOSXHillsClasses._CDynaSprite.h
     文件         512  2011-10-13 18:37  HillsClassesCDynaSprite.mm
     文件         273  2011-10-13 18:37  __MACOSXHillsClasses._CDynaSprite.mm
     文件         478  2011-11-03 02:25  HillsClassesCommon.h
     文件         273  2011-11-03 02:25  __MACOSXHillsClasses._Common.h
     文件        2190  2011-10-21 20:59  HillsClassesComputerPlayer.h
     文件         273  2011-10-21 20:59  __MACOSXHillsClasses._ComputerPlayer.h
     文件        5908  2011-11-03 01:31  HillsClassesComputerPlayer.mm
     文件         273  2011-11-03 01:31  __MACOSXHillsClasses._ComputerPlayer.mm
     文件         233  2011-10-24 00:12  HillsClassesDiffucultylayer.h
     文件         273  2011-10-24 00:12  __MACOSXHillsClasses._Diffucultylayer.h
     文件        2282  2011-10-25 20:27  HillsClassesDiffucultylayer.mm
     文件         273  2011-10-25 20:27  __MACOSXHillsClasses._Diffucultylayer.mm
     文件         269  2011-10-23 02:44  HillsClassesFloater.h
     文件         273  2011-10-23 02:44  __MACOSXHillsClasses._Floater.h
     文件        2198  2011-10-23 03:14  HillsClassesFloater.mm
     文件         273  2011-10-23 03:14  __MACOSXHillsClasses._Floater.mm
     文件         387  2011-10-25 20:44  HillsClassesFloater.plist
     文件         222  2011-10-25 20:44  __MACOSXHillsClasses._Floater.plist
     文件         531  2011-10-04 06:02  HillsClassesGameConfig.h
     文件         273  2011-10-04 06:02  __MACOSXHillsClasses._GameConfig.h
     文件        3165  2011-01-22 22:49  HillsClassesGameKitHelper.h
     文件         222  2011-01-22 22:49  __MACOSXHillsClasses._GameKitHelper.h
............此处省略1251个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)