2012-02-03 13:12:07.470 DuckHunting[174:707] cocos2d: cocos2d v1.0.1
2012-02-03 13:12:07.475 DuckHunting[174:707] cocos2d: Using Director Type:CCDirectorDisplayLink
2012-02-03 13:12:07.979 DuckHunting[174:707] cocos2d: OS version: 5.0.1 (0x05000100)
2012-02-03 13:12:07.981 DuckHunting[174:707] cocos2d: GL_VENDOR: Imagination Technologies
2012-02-03 13:12:07.982 DuckHunting[174:707] cocos2d: GL_RENDERER: PowerVR SGX 543
2012-02-03 13:12:07.984 DuckHunting[174:707] cocos2d: GL_VERSION: OpenGL ES-CM 1.1 IMGSGX543-63.14.2
2012-02-03 13:12:07.987 DuckHunting[174:707] cocos2d: GL_MAX_TEXTURE_SIZE: 4096
2012-02-03 13:12:07.988 DuckHunting[174:707] cocos2d: GL_MAX_MODELVIEW_STACK_DEPTH: 16
2012-02-03 13:12:07.989 DuckHunting[174:707] cocos2d: GL_MAX_SAMPLES: 4
2012-02-03 13:12:07.991 DuckHunting[174:707] cocos2d: GL supports PVRTC: YES
2012-02-03 13:12:07.992 DuckHunting[174:707] cocos2d: GL supports BGRA8888 textures: YES
2012-02-03 13:12:07.994 DuckHunting[174:707] cocos2d: GL supports NPOT textures: YES
2012-02-03 13:12:07.995 DuckHunting[174:707] cocos2d: GL supports discard_framebuffer: YES
2012-02-03 13:12:07.997 DuckHunting[174:707] cocos2d: compiled with NPOT support: NO
2012-02-03 13:12:07.998 DuckHunting[174:707] cocos2d: compiled with VBO support in TextureAtlas : YES
2012-02-03 13:12:07.999 DuckHunting[174:707] cocos2d: compiled with Affine Matrix transformation in CCNode : YES
2012-02-03 13:12:08.001 DuckHunting[174:707] cocos2d: compiled with Profiling Support: NO
2012-02-03 13:12:08.204 DuckHunting[174:707] cocos2d: surface size: 480x320
2012-02-03 13:12:08.391 DuckHunting[174:707] *** Assertion failure in -[CCTimer initWithTarget:selector:interval:], /Users/mouthofhands/Desktop/DuckHunting/DuckHunting/libs/cocos2d/CCScheduler.m:110
2012-02-03 13:12:08.393 DuckHunting[174:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Signature not found for selector - does it have the following form? -(void) name: (ccTime) dt'
*** First throw call stack:
(0x36ff88bf 0x316c61e5 0x36ff87b9 0x31a363b3 0x46f2d 0x48e07 0x349f5 0x92e21 0x32c11 0x92a3d 0x32c11 0x91fdf 0x325ca845 0x325c43bd 0x32592921 0x325923bf 0x32591d2d 0x31105df3 0x36fcc553 0x36fcc4f5 0x36fcb343 0x36f4e4dd 0x36f4e3a5 0x325c3457 0x325c0743 0x91c8f 0x2cc8)
terminate called throwing an exception
#import "GameplayLayer.h"
@implementation GameplayLayer
-(id)init {
[self scheduleUpdate];
self = [super init];
CGSize size =[[CCDirector sharedDirector] winSize];
if (self != nil) {
screenHeight = size.height;
srceenWidth = size.width;
// enable touches
duckSprite = [CCSprite spriteWithFile:@"duck1.png"
rect:CGRectMake(0, 0, 20, 20)];
duckSprite.position = ccp(100, screenHeight/2);
[self addChild:duckSprite];
CCAnimation *duckAnim = [CCAnimation animation];
[duckAnim addFrameWithFilename:@"duck1.png"];
[duckAnim addFrameWithFilename:@"duck2.png"];
id duckAnimationAction =
[CCAnimate actionWithDuration:0.5f
animation:duckAnim
restoreOriginalFrame:YES];
id repeatduckAnimation =
[CCRepeatForever actionWithAction:duckAnimationAction];
[duckSprite runAction:repeatduckAnimation];
crosshair = [CCSprite spriteWithFile:@"crosshair.png"
rect:CGRectMake(0, 0, 125, 125)];
[self addChild:crosshair];
crosshair.position = CGPointMake( size.width / 2, size.height / 2);
self.isAccelerometerEnabled = YES;
[self schedule:@selector(updatecrosshair:) interval:1.0/60.f];
CCMenuItem *shoot = [CCMenuItemImage itemFromNormalImage:@"Shootbutton.png" selectedImage:@"Shootbuttons.png" target:self selector:@selector(shootbuttonin:)];
shoot.position = ccp(450,30);
[self addChild:shoot];
}
return self;
}
- (void)shootbuttonin:(id)sender {
[[CCDirector sharedDirector] winSize];
CGRect duckRect = CGRectMake(
duckSprite.position.x - (duckSprite.contentSize.width/2),
duckSprite.position.y - (duckSprite.contentSize.height/2),
duckSprite.contentSize.width,
duckSprite.contentSize.height);
CGRect crosshairRect = CGRectMake(
crosshair.position.x - (crosshair.contentSize.width/2),
crosshair.position.y - (crosshair.contentSize.height/2),
crosshair.contentSize.width,
crosshair.contentSize.height);
if (CGRectIntersectsRect(duckRect, crosshairRect)) {
CCLOG(@"Collision!");
}
}
-(void) accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{
CCLOG(@"Acceleration Values are x:%f y:%f z:%f", acceleration.x , acceleration.y, acceleration.z );
tiltHorizontal = acceleration.y * 20;
tiltVertically = (acceleration.x + .4) *20;
CCLOG(@"tiltHorizontal is %i", tiltHorizontal );
}
- (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