私はObjective Cでプログラミングするのは初めてです。 私は少し単純な卓球ゲームを作っていますが、コンピュータプレーヤーのAIを作ろうとしている間、プログラムは常にスレッド1のSIGABRTエラーを表示しています。SIGABRTはどこからも出てこなかった
私はすでにここでこの質問をしましたが、本当に答えを得ていない、ちょうどより多くのコードを提供するように求められた。
エラーが実際に出てきていません編集コードが突然現れ、最後の成功した建物からコードを削除した後に突然それが表示されます。たとえ私が働いていることを知っているバックアップを開始しても。
ここにはすべてのコードがあります。
PongViewController.m - 私は、エラーの前に編集したコードは
#import "pongViewController.h"
#define kGameStateRunning 1
#define kGameStatePaused 2
#define kMicSpeedX 3
#define kMicSpeedY 4
#define ObtiznostPocitace 15
@implementation pongViewController
@synthesize mic,plosina_a,plosina_b,hrac_score,pocitac_score,gameState,micVelocity,TapToBegin;
- (void)viewDidLoad {
[super viewDidLoad];
self.gameState = kGameStatePaused;
micVelocity = CGPointMake(kMicSpeedX, kMicSpeedY);
[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(gameLoop) userInfo:nil repeats:YES];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if(gameState == kGameStatePaused) {
TapToBegin.hidden = YES;
gameState = kGameStateRunning;
} else if (gameState == kGameStateRunning) {
[self touchesMoved:touches withEvent:event];
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
CGPoint xLocation = CGPointMake(location.x,plosina_a.center.y);
plosina_a.center = xLocation;
}
- (void) gameLoop {
if(gameState == kGameStateRunning) {
mic.center = CGPointMake(mic.center.x + micVelocity.x, mic.center.y + micVelocity.y);
if(mic.center.x > self.view.bounds.size.width || mic.center.x < 0) {
micVelocity.x = -micVelocity.x;
}
if(mic.center.y > self.view.bounds.size.height || mic.center.y < 0) {
micVelocity.y = -micVelocity.y;
}
} else {
if (TapToBegin.hidden) {
TapToBegin.hidden = NO;
}
}
//Collision Detection
if (CGRectIntersectsRect(mic.frame,plosina_a.frame)) {
if (mic.center.y < plosina_a.center.y) {
micVelocity.y = -micVelocity.y;
//NSLog(@"%f %f", mic.center,plosina_b.center);
}
}
if (CGRectIntersectsRect(mic.frame,plosina_b.frame)) {
if (mic.center.y > plosina_b.center.y) {
micVelocity.y = -micVelocity.y;
}
}
if(mic.center.y <= self.view.center.y) {
if(mic.center.x < plosina_b.center.x) {
CGPoint compLocation = CGPointMake(plosina_b.center.x - ObtiznostPocitace, plosina_b.center.y);
plosina_b.center = compLocation;
}
if(mic.center.x > plosina_b.center.x) {
CGPoint compLocation = CGPointMake(plosina_b.center.x + ObtiznostPocitace, plosina_b.center.y);
plosina_b.center = compLocation;
}
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
//jakovždy nakonec uvolníme co sme si obsadili
- (void)dealloc {
[super dealloc];
[mic release];
[plosina_a release];
[plosina_b release];
[hrac_score release];
[pocitac_score release];
[TapToBegin release];
}
@end
main.mを示した - エラーはデバッガは何を吐き出している
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
を指しているコードを:
argc int 1
argv char ** 0xbffff6f4
*argv char * 0xbffff800
pool NSAutoreleasePool * 0x4b29340
NSObject NSObject {...}
_token void * 0x521a200
_reserved3 void * 0x0
_reserved2 void * 0x0
_reserved void * 0x0
retVal int -1073744132
これは(デバッガコンソールから)ですが、これはプロの一部ではないと思います邪悪だが、私は何を知っているのだろう。
This GDB was configured as "x86_64-apple-darwin".Attaching to process 11032.
Couldn't register com.yourcompany.pong with the bootstrap server. Error: unknown error code.
This generally means that another instance of this process was already running or is hung in the debugger.sharedlibrary apply-load-rules all
Current language: auto; currently objective-c
(gdb)
私がアプリケーションに持っていたすべての警告を修正しようとしましたが、私は成功しましたが、まだ何もしていません。
[スレッド1:プログラム受信信号SIGABRT]の可能な複製(http://stackoverflow.com/questions/7800134/thread-1-program-received-signal-sigabrt) – ughoavgfhw
ええ、それは私の質問でしたが、誰も答えず私はそれがどのように動作するのか知りませんが、私は何時の間にしてポストが失われ、誰にもそれに答えることができないと感じています。 –