1
A
回答
1
看看我的代码 - here are the sources。在HelloWorldLayer.m
中查找“移动”技术。我拍摄了360全景照片,并将其全屏连续地从右向左移动。
在你YourClass.h文件:
#import "cocos2d.h"
@interface YourClass : CCLayer
+(CCScene *) scene;
@end
在你YourClass.m文件:
#import "YourClass.h"
@implementation YourClass
CCSprite *panorama;
CCSprite *appendix;
//_____________________________________________________________________________________
+(CCScene *) scene
{
// 'scene' is an autorelease object.
CCScene *scene = [CCScene node];
// 'layer' is an autorelease object.
YourClass *layer = [YourClass node];
// add layer as a child to scene
[scene addChild: layer];
// return the scene
return scene;
}
//_____________________________________________________________________________________
// on "init" you need to initialize your instance
-(id) init
{
// always call "super" init
// Apple recommends to re-assign "self" with the "super" return value
if((self=[super init])) {
panorama = [CCSprite spriteWithFile: @"panorama.png"];
panorama.position = ccp(1709/2 , 320/2);
[self addChild:panorama];
appendix = [CCSprite spriteWithFile: @"appendix.png"];
appendix.position = ccp(1709+480/2-1, 320/2);
[self addChild:appendix];
// schedule a repeating callback on every frame
[self schedule:@selector(nextFrame:)];
}
return self;
}
//_____________________________________________________________________________________
- (void) nextFrame:(ccTime)dt {
panorama.position = ccp(panorama.position.x - 100 * dt, panorama.position.y);
appendix.position = ccp(appendix.position.x - 100 * dt, appendix.position.y);
if (panorama.position.x < -1709/2) {
panorama.position = ccp(1709/2 , panorama.position.y);
appendix.position = ccp(1709+480/2-1, appendix.position.y);
}
}
// on "dealloc" you need to release all your retained objects
- (void) dealloc
{
// in case you have something to dealloc, do it in this method
// in this particular example nothing needs to be released.
// cocos2d will automatically release all the children (Label)
// don't forget to call "super dealloc"
[super dealloc];
}
//_____________________________________________________________________________________
@end
用一下这个代码,你会得到你所需要的。
相关问题
- 1. cocos2D自动移动图像
- 2. 触摸在Cocos2d中移动
- 3. 在numpy中移动图像
- 4. 在pygame中移动图像
- 5. 在C#中移动图像
- 6. 在Android中移动图像
- 7. 在PictureBox中移动图像
- 8. 在pygame中移动图像?
- 9. 动画与cocos2d中的图像
- 10. 动画图像序列在cocos2d
- 11. 在图像视图中移动位图
- 12. 在图像中移动像素统计
- 13. 在cocos2d中动态绘图?
- 14. cocos2d移动物体
- 15. 移动背景 - Cocos2D
- 16. 在Android中动态地移动图像
- 17. 如何在视图中移动图像
- 18. 如何在cocos2d(python)中创建图像的按键触发器移动?
- 19. 如何在cocos2d中移动CCLayer
- 20. 如何在Cocos2d中移动CCMenu?
- 21. 如何在iPhone cocos2d中移动水?
- 22. 图像上的对象在图像移动时不会移动
- 23. 在图像元素内移动图像
- 24. 如何在cocos2d中垂直移动这些背景图像而不是水平移动?
- 25. SpaceManager中的对象Cocos2d正在移动或不移动?
- 26. 在HTML5画布中滚动(不移动图像)图像
- 27. 移动图像到中心
- 28. 在div内移动图像?
- 29. Cocos2d在路径上移动动画
- 30. 在Cocos2d中,如何移动背景精灵图片?