- 浏览: 774098 次
- 性别:
- 来自: 天堂
文章分类
最新评论
-
xiaozhao-521:
呀呀呀呀呀呀呀
RequestTest222 -
Andy_hyh:
打扰了,问下openmeeting源码可以运行起来吗?
Openmeetings安装 详细步骤 -
qindongliang1922:
擦,现在还行么,厉害
北京免费吃饭的地方 -
minixx77:
...
Openmeetings安装 详细步骤 -
wwwqqqiang:
喜欢楼主分享问题的方式,有思想
UIView 和 CALayer的那点事
AtlasSpriteManager :定义一个的精灵集合
AtlasSprite是一个CocosNode对象实现CocosNodeFrames和CocosNodeRGBA协议。
AtlasSprite可以作为替代的Sprite。
-(id) init
{
if( (self=[super init]) ) {
self.isTouchEnabled = YES; //TouchEnabled事件可用
//设定AtlasSpriteManager
AtlasSpriteManager *mgr = [AtlasSpriteManager spriteManagerWithFile:@"grossini_dance_atlas.png" capacity:50];
[self addChild:mgr z:0 tag:kTagSpriteManager]; //设定AtlasSpriteManager的引用值kTagSpriteManager,方便后面调用
//设定木sprite的座标点(ccp)
CGSize s = [[Director sharedDirector] winSize];
//定用自定义的方法 将定议的ccp传入过去
[self addNewSpriteWithCoords:ccp(s.width/2, s.height/2)];
}
return self;
}
-(void) addNewSpriteWithCoords:(CGPoint)p
{
AtlasSpriteManager *mgr = (AtlasSpriteManager*) [self getChildByTag:kTagSpriteManager]; //通过kTagSpriteManager调用AtlasSpriteManager值
int idx = CCRANDOM_0_1() * 1400 / 100; //定义一个0-14之间的随机数以便随机产生一个精灵
int x = (idx%5) * 85; //5:每行5个 宽度为85
int y = (idx/5) * 121; //高度为121
//以此来确定点的x,y座标
//通过CGRectMake值从spriteManager中取得相应的精灵
///CGRect CGRectMake( float x, float y, float width, float height )
AtlasSprite *sprite = [AtlasSprite spriteWithRect:CGRectMake(x,y,85,121) spriteManager:mgr];
[mgr addChild:sprite]; //添加精灵
sprite.position = ccp( p.x, p.y);
id action;
float rand = CCRANDOM_0_1(); //取0-1之间的随机数
//当rand值在不同的范围就执行不同的动作
if( rand < 0.20 )
action = [ScaleBy actionWithDuration:3 scale:2];
else if(rand < 0.40)
action = [RotateBy actionWithDuration:3 angle:360];
else if( rand < 0.60)
action = [Blink actionWithDuration:1 blinks:3];
else if( rand < 0.8 )
action = [TintBy actionWithDuration:2 red:0 green:-255 blue:-255];
else
action = [FadeOut actionWithDuration:2];
id action_back = [action reverse];
id seq = [Sequence actions:action, action_back, nil];
[sprite runAction: [RepeatForever actionWithAction:seq]];
}
//设置ccTouchesEnded事件
- (BOOL)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
for( UITouch *touch in touches ) {
//获得当前touch的位置
CGPoint location = [touch locationInView: [touch view]];
location = [[Director sharedDirector] convertCoordinate: location];
//重新调用函数执行
[self addNewSpriteWithCoords: location];
}
return kEventHandled;
}
例子二
@implementation Atlas2
-(id) init
{
if( (self=[super init]) ) {
AtlasSpriteManager *mgr = [AtlasSpriteManager spriteManagerWithFile:@"grossini_dance_atlas.png" capacity:50];
[self addChild:mgr z:0 tag:kTagSpriteManager];
AtlasSprite *sprite = [AtlasSprite spriteWithRect:CGRectMake(0, 0, 85, 121) spriteManager: mgr];
AtlasSprite *sprite2 = [AtlasSprite spriteWithRect:CGRectMake(0, 0, 85, 121) spriteManager: mgr];
AtlasSprite *sprite3 = [AtlasSprite spriteWithRect:CGRectMake(0, 0, 85, 121) spriteManager: mgr];
//为sprite增加一个动画
AtlasAnimation *animation = [AtlasAnimation animationWithName:@"dance" delay:0.2f];
for(int i=0;i<14;i++) {
int x= i % 5;
int y= i / 5;
//增加了一个帧的动画
[animation addFrameWithRect: CGRectMake(x*85, y*121, 85, 121) ];
}
[mgr addChild:sprite];
[mgr addChild:sprite2];
[mgr addChild:sprite3];
//设置精灵在场景中的位置
CGSize s = [[Director sharedDirector] winSize];
sprite.position = ccp( s.width /2, s.height/2);
sprite2.position = ccp( s.width /2 - 100, s.height/2);
sprite3.position = ccp( s.width /2 + 100, s.height/2);
//定义三个一样的动画
id action = [Animate actionWithAnimation: animation];
id action2 = [[action copy] autorelease];
id action3 = [[action copy] autorelease];
sprite.scale = 0.5f;
sprite2.scale = 1.0f;
sprite3.scale = 1.5f;
[sprite runAction:action];
[sprite2 runAction:action2];
[sprite3 runAction:action3];
}
return self;
}
-(NSString *) title
{
return @"AtlasSprite: Animation";
}
@end
例子三
#pragma mark Example Atlas 3
@implementation Atlas3
-(id) init
{
if( (self=[super init]) ) {
// small capacity. Testing resizing.
// Don't use capacity=1 in your real game. It is expensive to resize the capacity
AtlasSpriteManager *mgr = [AtlasSpriteManager spriteManagerWithFile:@"grossini_dance_atlas.png" capacity:1];
[self addChild:mgr z:0 tag:kTagSpriteManager];
//注意以下图片的取法,Y值不变的情况下 x值变化
AtlasSprite *sprite1 = [AtlasSprite spriteWithRect:CGRectMake(85*0, 121*1, 85, 121) spriteManager: mgr];
AtlasSprite *sprite2 = [AtlasSprite spriteWithRect:CGRectMake(85*1, 121*1, 85, 121) spriteManager: mgr];
AtlasSprite *sprite3 = [AtlasSprite spriteWithRect:CGRectMake(85*2, 121*1, 85, 121) spriteManager: mgr];
AtlasSprite *sprite4 = [AtlasSprite spriteWithRect:CGRectMake(85*3, 121*1, 85, 121) spriteManager: mgr];
AtlasSprite *sprite5 = [AtlasSprite spriteWithRect:CGRectMake(85*0, 121*1, 85, 121) spriteManager: mgr];
AtlasSprite *sprite6 = [AtlasSprite spriteWithRect:CGRectMake(85*1, 121*1, 85, 121) spriteManager: mgr];
AtlasSprite *sprite7 = [AtlasSprite spriteWithRect:CGRectMake(85*2, 121*1, 85, 121) spriteManager: mgr];
AtlasSprite *sprite8 = [AtlasSprite spriteWithRect:CGRectMake(85*3, 121*1, 85, 121) spriteManager: mgr];
CGSize s = [[Director sharedDirector] winSize];
//注意点位置的设法
sprite1.position = ccp( (s.width/5)*1, (s.height/3)*1);
sprite2.position = ccp( (s.width/5)*2, (s.height/3)*1);
sprite3.position = ccp( (s.width/5)*3, (s.height/3)*1);
sprite4.position = ccp( (s.width/5)*4, (s.height/3)*1);
sprite5.position = ccp( (s.width/5)*1, (s.height/3)*2);
sprite6.position = ccp( (s.width/5)*2, (s.height/3)*2);
sprite7.position = ccp( (s.width/5)*3, (s.height/3)*2);
sprite8.position = ccp( (s.width/5)*4, (s.height/3)*2);
id action = [FadeIn actionWithDuration:2];
id action_back = [action reverse];
id fade = [RepeatForever actionWithAction: [Sequence actions: action, action_back, nil]];
id tintred = [TintBy actionWithDuration:2 red:0 green:-255 blue:-255];
id tintred_back = [tintred reverse];
id red = [RepeatForever actionWithAction: [Sequence actions: tintred, tintred_back, nil]];
id tintgreen = [TintBy actionWithDuration:2 red:-255 green:0 blue:-255];
id tintgreen_back = [tintgreen reverse];
id green = [RepeatForever actionWithAction: [Sequence actions: tintgreen, tintgreen_back, nil]];
id tintblue = [TintBy actionWithDuration:2 red:-255 green:-255 blue:0];
id tintblue_back = [tintblue reverse];
id blue = [RepeatForever actionWithAction: [Sequence actions: tintblue, tintblue_back, nil]];
[sprite5 runAction:red];
[sprite6 runAction:green];
[sprite7 runAction:blue];
[sprite8 runAction:fade];
// late add: test dirtyColor and dirtyPosition
[mgr addChild:sprite1 z:0 tag:kTagSprite1];
[mgr addChild:sprite2 z:0 tag:kTagSprite2];
[mgr addChild:sprite3 z:0 tag:kTagSprite3];
[mgr addChild:sprite4 z:0 tag:kTagSprite4];
[mgr addChild:sprite5 z:0 tag:kTagSprite5];
[mgr addChild:sprite6 z:0 tag:kTagSprite6];
[mgr addChild:sprite7 z:0 tag:kTagSprite7];
[mgr addChild:sprite8 z:0 tag:kTagSprite8];
[self schedule:@selector(removeAndAddSprite:) interval:2];
}
return self;
}
// this function test if remove and add works as expected:
// color array and vertex array should be reindexed
//展示定时删除和添加一个精灵
-(void) removeAndAddSprite:(ccTime) dt
{
id mgr = [self getChildByTag:kTagSpriteManager];
id sprite = [mgr getChildByTag:kTagSprite5];
[sprite retain];
[mgr removeChild:sprite cleanup:NO];
[mgr addChild:sprite z:0 tag:kTagSprite5];
[sprite release];
}
-(NSString *) title
{
return @"AtlasSprite: Color & Opacity";
}
@end
例子四:AtlasSprite: Z order
-(void) reorderSprite:(ccTime) dt
{
id mgr = [self getChildByTag:kTagSpriteManager]; //众Layer中得到SpriteManager
id sprite = [mgr getChildByTag:kTagSprite1]; //从SpriteManager得到精灵
int z = [sprite zOrder];
if( z < -1 )
dir = 1;
if( z > 10 )
dir = -1;
z += dir * 3;
//重新更改精灵的显示顺序,顺序越大显示越前面
[mgr reorderChild:sprite z:z];
}
例子五:AtlasZVertex
for(int i=0;i<5;i++) {
AtlasSprite *sprite = [AtlasSprite spriteWithRect:CGRectMake(85*0, 121*1, 85, 121) spriteManager: mgr];
sprite.position = ccp( 50 + i*40, s.height/2);
//形成队列效果,vertexz值越大精灵越大,显示越前面
sprite.vertexZ = 10 + i*40;
[mgr addChild:sprite z:0];
}
//转动特效
[self runAction:[OrbitCamera actionWithDuration:10 radius: 1 deltaRadius:0 angleZ:0 deltaAngleZ:360 angleX:0 deltaAngleX:0]];
例子六:anchorPoint
anchorPoint
//以下例子精灵将以anchorPoint的点的位置为中心进行转动
@implementation Atlas5
-(id) init
{
if( (self=[super init]) ) {
// small capacity. Testing resizing.
// Don't use capacity=1 in your real game. It is expensive to resize the capacity
AtlasSpriteManager *mgr = [AtlasSpriteManager spriteManagerWithFile:@"grossini_dance_atlas.png" capacity:1];
[self addChild:mgr z:0 tag:kTagSpriteManager];
CGSize s = [[Director sharedDirector] winSize];
id rotate = [RotateBy actionWithDuration:10 angle:360];
id action = [RepeatForever actionWithAction:rotate];
for(int i=0;i<3;i++) {
AtlasSprite *sprite = [AtlasSprite spriteWithRect:CGRectMake(85*i, 121*1, 85, 121) spriteManager: mgr];
sprite.position = ccp( 90 + i*150, s.height/2);
Sprite *point = [Sprite spriteWithFile:@"r1.png"];
point.scale = 0.25f;
point.position = sprite.position;
[self addChild:point z:1];
switch(i) {
case 0:
sprite.anchorPoint = CGPointZero;
break;
case 1:
sprite.anchorPoint = ccp(0.5f, 0.5f);
break;
case 2:
sprite.anchorPoint = ccp(1,1);
break;
}
point.position = sprite.position;
id copy = [[action copy] autorelease];
[sprite runAction:copy];
[mgr addChild:sprite z:i];
}
}
return self;
}
-(NSString *) title
{
return @"AtlasSprite: anchor point";
}
AtlasSprite has all the features from CocosNode with the following additions and limitations:
- New features(新的特征)
- It is MUCH faster than Sprite
- supports flipX, flipY
- Limitations(一些限制)
- Their parent can only be an AtlasSpriteManager
- They can't have children
- Camera is not supported yet (eg: OrbitCamera action doesn't work)
- GridBase actions are not supported (eg: Lens, Ripple, Twirl)
- The Alias/Antialias property belongs to AtlasSpriteManager, so you can't individually set the aliased property.
- The Blending function property belongs to AtlasSpriteManager, so you can't individually set the blending function property.
- Parallax scroller is not supported, but can be simulated with a "proxy" sprite.
例子一
-(id) init
{
if( (self=[super init]) ) {
self.isTouchEnabled = YES; //TouchEnabled事件可用
//设定AtlasSpriteManager
AtlasSpriteManager *mgr = [AtlasSpriteManager spriteManagerWithFile:@"grossini_dance_atlas.png" capacity:50];
[self addChild:mgr z:0 tag:kTagSpriteManager]; //设定AtlasSpriteManager的引用值kTagSpriteManager,方便后面调用
//设定木sprite的座标点(ccp)
CGSize s = [[Director sharedDirector] winSize];
//定用自定义的方法 将定议的ccp传入过去
[self addNewSpriteWithCoords:ccp(s.width/2, s.height/2)];
}
return self;
}
-(void) addNewSpriteWithCoords:(CGPoint)p
{
AtlasSpriteManager *mgr = (AtlasSpriteManager*) [self getChildByTag:kTagSpriteManager]; //通过kTagSpriteManager调用AtlasSpriteManager值
int idx = CCRANDOM_0_1() * 1400 / 100; //定义一个0-14之间的随机数以便随机产生一个精灵
int x = (idx%5) * 85; //5:每行5个 宽度为85
int y = (idx/5) * 121; //高度为121
//以此来确定点的x,y座标
//通过CGRectMake值从spriteManager中取得相应的精灵
///CGRect CGRectMake( float x, float y, float width, float height )
AtlasSprite *sprite = [AtlasSprite spriteWithRect:CGRectMake(x,y,85,121) spriteManager:mgr];
[mgr addChild:sprite]; //添加精灵
sprite.position = ccp( p.x, p.y);
id action;
float rand = CCRANDOM_0_1(); //取0-1之间的随机数
//当rand值在不同的范围就执行不同的动作
if( rand < 0.20 )
action = [ScaleBy actionWithDuration:3 scale:2];
else if(rand < 0.40)
action = [RotateBy actionWithDuration:3 angle:360];
else if( rand < 0.60)
action = [Blink actionWithDuration:1 blinks:3];
else if( rand < 0.8 )
action = [TintBy actionWithDuration:2 red:0 green:-255 blue:-255];
else
action = [FadeOut actionWithDuration:2];
id action_back = [action reverse];
id seq = [Sequence actions:action, action_back, nil];
[sprite runAction: [RepeatForever actionWithAction:seq]];
}
//设置ccTouchesEnded事件
- (BOOL)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
for( UITouch *touch in touches ) {
//获得当前touch的位置
CGPoint location = [touch locationInView: [touch view]];
location = [[Director sharedDirector] convertCoordinate: location];
//重新调用函数执行
[self addNewSpriteWithCoords: location];
}
return kEventHandled;
}
例子二
@implementation Atlas2
-(id) init
{
if( (self=[super init]) ) {
AtlasSpriteManager *mgr = [AtlasSpriteManager spriteManagerWithFile:@"grossini_dance_atlas.png" capacity:50];
[self addChild:mgr z:0 tag:kTagSpriteManager];
AtlasSprite *sprite = [AtlasSprite spriteWithRect:CGRectMake(0, 0, 85, 121) spriteManager: mgr];
AtlasSprite *sprite2 = [AtlasSprite spriteWithRect:CGRectMake(0, 0, 85, 121) spriteManager: mgr];
AtlasSprite *sprite3 = [AtlasSprite spriteWithRect:CGRectMake(0, 0, 85, 121) spriteManager: mgr];
//为sprite增加一个动画
AtlasAnimation *animation = [AtlasAnimation animationWithName:@"dance" delay:0.2f];
for(int i=0;i<14;i++) {
int x= i % 5;
int y= i / 5;
//增加了一个帧的动画
[animation addFrameWithRect: CGRectMake(x*85, y*121, 85, 121) ];
}
[mgr addChild:sprite];
[mgr addChild:sprite2];
[mgr addChild:sprite3];
//设置精灵在场景中的位置
CGSize s = [[Director sharedDirector] winSize];
sprite.position = ccp( s.width /2, s.height/2);
sprite2.position = ccp( s.width /2 - 100, s.height/2);
sprite3.position = ccp( s.width /2 + 100, s.height/2);
//定义三个一样的动画
id action = [Animate actionWithAnimation: animation];
id action2 = [[action copy] autorelease];
id action3 = [[action copy] autorelease];
sprite.scale = 0.5f;
sprite2.scale = 1.0f;
sprite3.scale = 1.5f;
[sprite runAction:action];
[sprite2 runAction:action2];
[sprite3 runAction:action3];
}
return self;
}
-(NSString *) title
{
return @"AtlasSprite: Animation";
}
@end
例子三
#pragma mark Example Atlas 3
@implementation Atlas3
-(id) init
{
if( (self=[super init]) ) {
// small capacity. Testing resizing.
// Don't use capacity=1 in your real game. It is expensive to resize the capacity
AtlasSpriteManager *mgr = [AtlasSpriteManager spriteManagerWithFile:@"grossini_dance_atlas.png" capacity:1];
[self addChild:mgr z:0 tag:kTagSpriteManager];
//注意以下图片的取法,Y值不变的情况下 x值变化
AtlasSprite *sprite1 = [AtlasSprite spriteWithRect:CGRectMake(85*0, 121*1, 85, 121) spriteManager: mgr];
AtlasSprite *sprite2 = [AtlasSprite spriteWithRect:CGRectMake(85*1, 121*1, 85, 121) spriteManager: mgr];
AtlasSprite *sprite3 = [AtlasSprite spriteWithRect:CGRectMake(85*2, 121*1, 85, 121) spriteManager: mgr];
AtlasSprite *sprite4 = [AtlasSprite spriteWithRect:CGRectMake(85*3, 121*1, 85, 121) spriteManager: mgr];
AtlasSprite *sprite5 = [AtlasSprite spriteWithRect:CGRectMake(85*0, 121*1, 85, 121) spriteManager: mgr];
AtlasSprite *sprite6 = [AtlasSprite spriteWithRect:CGRectMake(85*1, 121*1, 85, 121) spriteManager: mgr];
AtlasSprite *sprite7 = [AtlasSprite spriteWithRect:CGRectMake(85*2, 121*1, 85, 121) spriteManager: mgr];
AtlasSprite *sprite8 = [AtlasSprite spriteWithRect:CGRectMake(85*3, 121*1, 85, 121) spriteManager: mgr];
CGSize s = [[Director sharedDirector] winSize];
//注意点位置的设法
sprite1.position = ccp( (s.width/5)*1, (s.height/3)*1);
sprite2.position = ccp( (s.width/5)*2, (s.height/3)*1);
sprite3.position = ccp( (s.width/5)*3, (s.height/3)*1);
sprite4.position = ccp( (s.width/5)*4, (s.height/3)*1);
sprite5.position = ccp( (s.width/5)*1, (s.height/3)*2);
sprite6.position = ccp( (s.width/5)*2, (s.height/3)*2);
sprite7.position = ccp( (s.width/5)*3, (s.height/3)*2);
sprite8.position = ccp( (s.width/5)*4, (s.height/3)*2);
id action = [FadeIn actionWithDuration:2];
id action_back = [action reverse];
id fade = [RepeatForever actionWithAction: [Sequence actions: action, action_back, nil]];
id tintred = [TintBy actionWithDuration:2 red:0 green:-255 blue:-255];
id tintred_back = [tintred reverse];
id red = [RepeatForever actionWithAction: [Sequence actions: tintred, tintred_back, nil]];
id tintgreen = [TintBy actionWithDuration:2 red:-255 green:0 blue:-255];
id tintgreen_back = [tintgreen reverse];
id green = [RepeatForever actionWithAction: [Sequence actions: tintgreen, tintgreen_back, nil]];
id tintblue = [TintBy actionWithDuration:2 red:-255 green:-255 blue:0];
id tintblue_back = [tintblue reverse];
id blue = [RepeatForever actionWithAction: [Sequence actions: tintblue, tintblue_back, nil]];
[sprite5 runAction:red];
[sprite6 runAction:green];
[sprite7 runAction:blue];
[sprite8 runAction:fade];
// late add: test dirtyColor and dirtyPosition
[mgr addChild:sprite1 z:0 tag:kTagSprite1];
[mgr addChild:sprite2 z:0 tag:kTagSprite2];
[mgr addChild:sprite3 z:0 tag:kTagSprite3];
[mgr addChild:sprite4 z:0 tag:kTagSprite4];
[mgr addChild:sprite5 z:0 tag:kTagSprite5];
[mgr addChild:sprite6 z:0 tag:kTagSprite6];
[mgr addChild:sprite7 z:0 tag:kTagSprite7];
[mgr addChild:sprite8 z:0 tag:kTagSprite8];
[self schedule:@selector(removeAndAddSprite:) interval:2];
}
return self;
}
// this function test if remove and add works as expected:
// color array and vertex array should be reindexed
//展示定时删除和添加一个精灵
-(void) removeAndAddSprite:(ccTime) dt
{
id mgr = [self getChildByTag:kTagSpriteManager];
id sprite = [mgr getChildByTag:kTagSprite5];
[sprite retain];
[mgr removeChild:sprite cleanup:NO];
[mgr addChild:sprite z:0 tag:kTagSprite5];
[sprite release];
}
-(NSString *) title
{
return @"AtlasSprite: Color & Opacity";
}
@end
例子四:AtlasSprite: Z order
-(void) reorderSprite:(ccTime) dt
{
id mgr = [self getChildByTag:kTagSpriteManager]; //众Layer中得到SpriteManager
id sprite = [mgr getChildByTag:kTagSprite1]; //从SpriteManager得到精灵
int z = [sprite zOrder];
if( z < -1 )
dir = 1;
if( z > 10 )
dir = -1;
z += dir * 3;
//重新更改精灵的显示顺序,顺序越大显示越前面
[mgr reorderChild:sprite z:z];
}
例子五:AtlasZVertex
for(int i=0;i<5;i++) {
AtlasSprite *sprite = [AtlasSprite spriteWithRect:CGRectMake(85*0, 121*1, 85, 121) spriteManager: mgr];
sprite.position = ccp( 50 + i*40, s.height/2);
//形成队列效果,vertexz值越大精灵越大,显示越前面
sprite.vertexZ = 10 + i*40;
[mgr addChild:sprite z:0];
}
//转动特效
[self runAction:[OrbitCamera actionWithDuration:10 radius: 1 deltaRadius:0 angleZ:0 deltaAngleZ:360 angleX:0 deltaAngleX:0]];
例子六:anchorPoint
anchorPoint
:
特定的锚点坐标锚点。(0,0)指左下角,(1,1)指右上角,(0.5,0.5)指中心。精灵和其他“textured”节点有一个缺省值(0.5f,0.5f默认anchorPoint)//以下例子精灵将以anchorPoint的点的位置为中心进行转动
@implementation Atlas5
-(id) init
{
if( (self=[super init]) ) {
// small capacity. Testing resizing.
// Don't use capacity=1 in your real game. It is expensive to resize the capacity
AtlasSpriteManager *mgr = [AtlasSpriteManager spriteManagerWithFile:@"grossini_dance_atlas.png" capacity:1];
[self addChild:mgr z:0 tag:kTagSpriteManager];
CGSize s = [[Director sharedDirector] winSize];
id rotate = [RotateBy actionWithDuration:10 angle:360];
id action = [RepeatForever actionWithAction:rotate];
for(int i=0;i<3;i++) {
AtlasSprite *sprite = [AtlasSprite spriteWithRect:CGRectMake(85*i, 121*1, 85, 121) spriteManager: mgr];
sprite.position = ccp( 90 + i*150, s.height/2);
Sprite *point = [Sprite spriteWithFile:@"r1.png"];
point.scale = 0.25f;
point.position = sprite.position;
[self addChild:point z:1];
switch(i) {
case 0:
sprite.anchorPoint = CGPointZero;
break;
case 1:
sprite.anchorPoint = ccp(0.5f, 0.5f);
break;
case 2:
sprite.anchorPoint = ccp(1,1);
break;
}
point.position = sprite.position;
id copy = [[action copy] autorelease];
[sprite runAction:copy];
[mgr addChild:sprite z:i];
}
}
return self;
}
-(NSString *) title
{
return @"AtlasSprite: anchor point";
}
发表评论
-
iOS 自定义UIActionSheet
2012-12-18 16:07 16425一:模态视图 UIActi ... -
UIView 和 CALayer的那点事
2012-11-17 23:51 30784UIView 和 CALayer的那点事 (1 ... -
iOS Open Source : Popover API for iPhone
2012-01-20 15:02 1948http://iphonedevelopertips.com/ ... -
ios 任务、线程、定时器
2011-12-26 18:09 8032一:operations(任务) cocoa提供了三种 ... -
ios url缓存策略——NSURLCache、 NSURLRequest
2011-12-26 17:09 24360一:url 缓存策略 NSURLRequest ... -
ios NSInvocation简单使用
2011-12-22 16:39 6379在ios直接调用某个对象的消息是方法有两种: 一:perfo ... -
iphone 对Web Services的三种请求方式soap get post
2011-11-09 10:57 6444一:Using SO AP 1.1 POST / ... -
sdk3.2手势实例
2011-11-09 10:11 1747#import <UIKit/UIKit.h>@i ... -
关于iphone 利用hpple解析html的问题
2011-08-04 18:28 2229最近在用happe解析html中的图片。有个翻页操作,如果请 ... -
iphone hpple 解析html,xml
2011-07-19 16:21 2755使用Objective-C解析HTML或者XML,系统自带有两 ... -
激活 iPhone通过 GPRS 连接服务器功能的代码
2011-05-13 15:14 1663如果您的 iPhone 应用里含有连接服务器的功能,也许会遇到 ... -
address book api 图型
2011-04-28 15:51 1151最近要搞地址簿了,整理一下 -
[OmniGraffle]iPhone app原型制作工具
2011-04-06 17:35 3962在写程序之前,我们通常需要做一些mockup出来(不知道款爷有 ... -
自定义uislider 样式
2011-04-04 21:28 3844UIImage *stetchLeftTrack= [[UII ... -
iphone 下AsyncSocket网络库编程
2011-04-02 21:04 7648iphone的标准推荐CFNetwork ... -
进阶AlertView运用 - 登入设计
2011-04-01 17:52 3043说明:示范如何利用AlertView来制作系统登入的介面程式碼 ... -
iPad UIPopoverController弹出窗口的位置和坐标
2011-04-01 17:42 2008优化规则: TodoViewControlle ... -
iPhone系统自动化测试
2011-04-01 17:39 2626首先mac系统是必备的2 安装iPhone SD ... -
iphone上面编写具有root权限的程序
2011-04-01 17:31 6302正常途径下, 我们编写的程序发布在App store上, 使用 ... -
聊天。。。。。
2011-04-01 17:13 1096是得分手段
相关推荐
"Cocos2d API"是指该框架提供的应用程序编程接口,开发者可以通过这些API来构建游戏逻辑、处理图形渲染、动画效果、音频管理以及用户输入等。 Cocos2d API主要包括以下几个核心模块: 1. **Director**:这是Cocos...
【cocos2d-x API中文文档】是一份详尽的资料,主要涵盖了cocos2d-x游戏引擎的API,这份文档适用于2015年的最新版本。cocos2d-x是一个基于MIT许可证的开源游戏引擎,它以快速、简单且功能强大的特性闻名,允许开发者...
Cocos2d-js API中文文档是一份非常重要的资源,它为开发者提供了全面的Cocos2d-js框架的接口和功能介绍。Cocos2d-js是一个基于C++开发的游戏引擎,它将Cocos2d-x的功能与JavaScript语言相结合,使得游戏开发更加便捷...
Cocos2d的API文档通常包含详细的技术指导、类库参考以及方法描述,为开发者提供了一个高效索引的资料库。 在描述中提到的"chm"格式文件是一种Microsoft编写的帮助文件格式,全称为Compiled HTML Help,它可以将HTML...
cocos api 文档。我想大家都需要,就共享给大家,不用找的那么麻烦了
《cocos2d-3.0 API文档详解》 cocos2d-3.0是一款强大的2D游戏开发框架,广泛应用于iOS、Android以及其他多平台的游戏开发。它提供了丰富的功能和高效的性能,使得开发者能够轻松地创建出各种类型的游戏。这份文档是...
资源名称:Cocos2d-x实战:JS卷——Cocos2d-JS开发内容简介:本书是介绍Cocos2d-x游戏编程和开发技术书籍,介绍了使用Cocos2d-JS中核心类、瓦片地图、物理引擎、音乐音效、数据持久化、网络通信、性能优化、多平台...
《cocos2d-x API大全中文版2016》是一部详尽的参考资料,旨在为开发者提供关于cocos2d-x框架的全面理解和实践指导。cocos2d-x是一款广泛使用的开源游戏开发框架,它基于cocos2d,并且支持跨平台开发,包括iOS、...
此外,cocos2d-x的事件系统也是其核心特性之一。它允许开发者方便地处理触摸、键盘、鼠标等各种输入事件,构建出响应性强的交互界面。同时,它的动作(Actions)和动画(Animations)系统,让开发者能够轻松实现复杂...
为了深入学习和使用Cocos2d-html5 API,开发者可以打开提供的参考文档,通过Google浏览器访问`cocos2d-x\www.cocos2d-x.org\reference\html5-js\index.html`。这个文档详细介绍了每个类、方法和属性,以及如何在实际...
2. **图形与动画**:讲解如何使用Cocos2d-x的绘图API绘制2D图形,实现精灵(Sprite)、动画(Animation)和粒子系统(Particle System)。 3. **物理引擎**:介绍Cocos2d-x内置的Box2D物理引擎,用于模拟游戏中的...
3. **Cocos2d API**:这个版本提供了与Cocos2d-x相似的API,使得开发者可以从Cocos2d-x轻松过渡到Cocos2d-html5。这些API包括精灵(Sprite)、层(Layer)、场景(Scene)、动作(Actions)等,它们构成了游戏的基本...
### cocos2d-iphone至cocos2d-html5移植之旅:深入解析与实践指南 #### 引言 在数字化时代,跨平台游戏开发成为了一种趋势,尤其在移动设备和网页端之间的转换变得日益频繁。《cocos2d-iphone至cocos2d-html5移植...
在Android平台上,Cocos2d-x是一个基于C++的版本,提供了原生的编程接口,同时也支持Java API,方便Android开发者使用。"cocos2d-android jar包全套.zip"这个压缩包包含了在Android上使用Cocos2d开发游戏所需的所有...
《cocos2d-x 3.8:经典游戏引擎源码解析》 cocos2d-x 是一个跨平台的游戏开发框架,它基于C++,同时提供了Lua和JavaScript的绑定,让开发者可以方便地在多种操作系统上创建2D游戏、演示程序和其他图形交互应用。这...
《Cocos2d-lua核心编程内置代码》深入解析 Cocos2d-lua是一款基于Cocos2d-x引擎的轻量级游戏开发框架,它将强大的C++底层引擎与灵活易用的Lua脚本语言相结合,为游戏开发者提供了一个高效、便捷的游戏开发平台。在...
总的来说,《Cocos2d-x 3.x游戏开发实战》是一本全面覆盖Cocos2d-x 3.x开发技术的指南,它不仅教授基本概念和技术,还通过实例深入解析游戏开发的各个层面。无论你是初学者还是有一定经验的开发者,这本书都能提供...
欢迎下载cocos2d-x3.6API参考手册(英文)。
1. 学习cocos2d-x 3.0的官方文档,了解其核心类和API。 2. 研究cocos2d-x社区的教程和示例项目,积累实战经验。 3. 探索Box2D物理引擎,提升游戏的物理表现力。 4. 实践编程,通过修改和调试代码,理解行走逻辑的每...
cocos2d-android游戏引擎是著名游戏引擎cocos2d游戏引擎的Android版。cocos2d-android游戏引擎性能优越、易学、可以进行纯java编程、具有极高的研 究价值、大大的降低了开发者的学习成本。您只需要一台普通配置的...