0

このメソッドを呼び出す必要があります:

[super initWithPNGFileName: "/Volumes/SAGITTER/Lavoro/Progetti xCode/IVBricker test/ball.png" andGame:game andCGRect:CGRectMake(x,y,16,16)];

だから私がこれをiPhoneに置いたとき、道は正しくない。NSBundleを使用する必要があることはわかっていますが、使用する場合

[super initWithPNGFileName:[[NSBundle mainBundle] pathForResource:@"ball" ofType:@"png" inDirectory:@"/"] andGame:game andCGRect:CGRectMake(x,y,16,16)];

「互換性のないポインタ型から'initWithPNGFileName:andGame:andCGRect:'の引数1を渡す」というアラートが表示されます

NSBundleの使用をどのように進めればよいですか?

4

2 に答える 2

0

最初の呼び出しはc-stringをinitWithPNGFileName:メソッドに渡し、 -pathForResource:NSStringを返します。バンドルから取得したパスからc-stringを取得し、その文字列をメソッドに渡します。

[super initWithPNGFileName:[[[NSBundle mainBundle] pathForResource:@"ball" ofType:@"png" inDirectory:@"/"] UTF8String]
                   andGame:game 
                 andCGRect:CGRectMake(x,y,16,16)];
于 2011-03-02T10:05:55.480 に答える
0

が100%正しいコードの場合[super initWithPNGFileName: "/Volum...、このメッセージはCスタイルの文字列を想定していると思います。
ただし[[NSBundle mainBundle] pathForResource:...]、NSStringオブジェクトを返します。

[[[NSBundle mainBundle] pathForResource:@"ball" ofType:@"png" inDirectory:@"/"] cStringUsingEncoding:NSUTF8StringEncoding]メソッドに渡してみてください。

于 2011-03-02T10:06:35.370 に答える