运行以下代码只有r和实体会旋转但是enemyEntity不会。我在rotateBy的update方法中添加了一个调用,并且只在enemyEntity上运行rotateBy,它会调用它并改变角度但不显示效果。我认为是继承问题。我发布了下面的代码和本页底部的标题。有什么建议吗?
CCSprite *r = [CCSprite spriteWithFile:@"redRingRight.png"];
r.anchorPoint = CGPointMake(0.5f, 0.5f);
r.position = CGPointMake(160.0f, 60.0f);
[r runAction:[CCRotateBy actionWithDuration:2.0f angle:100]];
[self addChild:r z:0 tag:77];
Entity * entity = [Entity spriteWithFile:@"redRingRight.png"];
entity.anchorPoint = CGPointMake(0.5f, 0.5f);
entity.position = CGPointMake(160.0f, 200.0f);
[entity runAction: [CCRotateBy actionWithDuration:2.0f angle:100]];
[self addChild:entity];
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"game-art-hd.plist"];
EnemyEntity * enemyEntity = [EnemyEntity enemyWithType:Boss];
enemyEntity.visible = TRUE;
enemyEntity.anchorPoint = CGPointMake(0.5f, 0.5f);
enemyEntity.position = CGPointMake(160.0f, 300.0f);
[enemyEntity runAction: [CCRotateBy actionWithDuration:2.0f angle:100]];
[self addChild:enemyEntity];
//[self scheduleUpdate];
Entity和EnemyEntity(实体的子类)的标题:
Entity.h
#import <Foundation/Foundation.h>
#import "cocos2d.h"
@class Component;
@interface Entity : CCSprite
{
}
@end
EnemyEntity.h
#import <Foundation/Foundation.h>
#import "Entity.h"
typedef enum
{
...,
Boss,
..
} EnemyTypes;
@interface EnemyEntity : Entity
{
EnemyTypes type;
}
+(id) enemyWithType :(EnemyTypes)enemyType ;
-(void) spawn;
@end
答案 0 :(得分:0)
我从头开始重写代码,现在它确实旋转了。可能是@ LearnCocos2D的建议:“检查是否有任何其他代码正在运行,可能会重置旋转。您可以在CCNode旋转属性上设置断点。”。
谢谢!