设备 cocos2d-v2
眼下cocos2d-v3也不太稳定,它在很大程度上仍然是变化的功能。
对于稳定。我们仍然使用 v2
wget -c http://cocos2d-iphone.googlecode.com/files/cocos2d-iphone-2.1.tar.gz
//
// BackgroundLayer.m
// cc2
//
// Created by HeJiasheng on 13-11-20.
// Copyright (c) 2013年 HeJiasheng. All rights reserved.
//
#import "BackgroundLayer.h"
@implementation BackgroundLayer
-(id)init {
self = [super init];
if (self != nil) {
CCSprite *backgroundImage = [CCSprite spriteWithFile:@"backgroundiPhone.png"];
CGSize screenSize = [[CCDirector sharedDirector] winSize];
[backgroundImage setPosition:CGPointMake(screenSize.width/2, screenSize.height/2)];
[self addChild:backgroundImage z:0 tag:0];
}
return self;
}
@end
//
// GameplayLayer.m
// cc2
//
// Created by HeJiasheng on 13-11-20.
// Copyright (c) 2013年 HeJiasheng. All rights reserved.
//
#import "GameplayLayer.h"
@implementation GameplayLayer
-(id)init {
self = [super init];
if (self != nil) {
CCSprite *vikingSprite = [CCSprite spriteWithFile:@"sv_anim_1.png"];
CGSize screenSize = [[CCDirector sharedDirector] winSize];
[vikingSprite setPosition:CGPointMake(screenSize.width/2, screenSize.height/2)];
[self addChild:vikingSprite z:5 tag:0];
}
return self;
}
@end
//
// GameScene.m
// cc2
//
// Created by HeJiasheng on 13-11-20.
// Copyright (c) 2013年 HeJiasheng. All rights reserved.
//
#import "GameScene.h"
@implementation GameScene
-(id)init {
self = [super init];
if (self != nil) {
BackgroundLayer *backgroundlayer = [BackgroundLayer node];
[self addChild:backgroundlayer z:0];
GameplayLayer *gameplayLayer = [GameplayLayer node];
[self addChild:gameplayLayer z:5];
}
return self;
}
@end
-(void) onEnter
{
[super onEnter];
//[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:[HelloWorldLayer scene] ]];
[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:[GameScene node]]];
}
版权声明:本文博主原创文章,博客,未经同意不得转载。
时间: 2024-11-10 07:51:59