Added a bit of moves
This commit is contained in:
parent
e0edd4d549
commit
04dadc9e41
4 changed files with 42 additions and 8 deletions
|
@ -42,7 +42,7 @@
|
|||
#error(unknown architecture)
|
||||
#endif
|
||||
|
||||
#define GAME_AUTOROTATION kGameAutorotationNone
|
||||
#define GAME_AUTOROTATION kGameAutorotationUIViewController
|
||||
|
||||
#endif // __GAME_CONFIG_H
|
||||
|
||||
|
|
|
@ -9,8 +9,10 @@
|
|||
#import "cocos2d.h"
|
||||
|
||||
@interface MainLayer : CCLayer {
|
||||
CGSize winSize;
|
||||
CCSprite *starship;
|
||||
NSMutableArray *bullets;
|
||||
NSMutableArray *enemis;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#import "MainLayer.h"
|
||||
#import "Constants.h"
|
||||
#import "CCTouchDispatcher.h"
|
||||
|
||||
@implementation MainLayer
|
||||
|
||||
|
@ -15,7 +16,7 @@
|
|||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
CGSize winSize = [[CCDirector sharedDirector] winSize];
|
||||
winSize = [[CCDirector sharedDirector] winSize];
|
||||
|
||||
starship = [[CCSprite alloc] initWithFile:@"Vaisseau.png"];
|
||||
starship.position = ccp(40, 40);
|
||||
|
@ -33,12 +34,43 @@
|
|||
100 + (rand() % ((int)winSize.height - 100)));
|
||||
[self addChild:enemy];
|
||||
}
|
||||
self.isTouchEnabled = YES;
|
||||
[self schedule:@selector(nextFrame:)];
|
||||
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void) registerWithTouchDispatcher
|
||||
{
|
||||
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
|
||||
}
|
||||
|
||||
-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
|
||||
{
|
||||
[[CCDirector sharedDirector] resume];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (void) ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event
|
||||
{
|
||||
[[CCDirector sharedDirector] pause];
|
||||
}
|
||||
|
||||
/*
|
||||
- (void) ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
|
||||
}*/
|
||||
|
||||
- (void) nextFrame:(ccTime)dt
|
||||
{
|
||||
starship.position = ccp((int)(starship.position.x + (winSize.width*dt) ) % ((int)winSize.width),40);
|
||||
}
|
||||
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[starship release];
|
||||
|
|
|
@ -67,10 +67,10 @@
|
|||
//
|
||||
// Sample: Autorotate only in landscape mode
|
||||
//
|
||||
if( interfaceOrientation == UIInterfaceOrientationLandscapeLeft ) {
|
||||
[[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeRight];
|
||||
} else if( interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
|
||||
[[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeLeft];
|
||||
if( interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ) {
|
||||
[[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationPortraitUpsideDown];
|
||||
} else if( interfaceOrientation == UIInterfaceOrientationPortrait) {
|
||||
[[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationPortrait];
|
||||
}
|
||||
|
||||
// Since this method should return YES in at least 1 orientation,
|
||||
|
@ -85,7 +85,7 @@
|
|||
//
|
||||
// return YES for the supported orientations
|
||||
|
||||
return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );
|
||||
return ( UIInterfaceOrientationIsPortrait( interfaceOrientation ) );
|
||||
|
||||
#else
|
||||
#error Unknown value in GAME_AUTOROTATION
|
||||
|
@ -93,7 +93,7 @@
|
|||
#endif // GAME_AUTOROTATION
|
||||
|
||||
|
||||
// Shold not happen
|
||||
// Should not happen
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue