<非互換項目>
- タッチイベントを処理する重要なクラスと位置付けられていると思っていたCCLayerクラスが無くなっている。
- タッチイベント有効化やイベント名自体も変更されている。
<対応方法>
- CCLayerクラスの置き換え
・CCLayer → CCNodeクラスへ置き換えます。 - タッチイベント有効化
・「self.touchEnabled = YES;」→「self.userInteractionEnabled = YES;」へ変更 - タッチイベント処理オーバーライドメソッドの変更
・下記、対応例を参照。
// タッチイベント有効化
self.touchEnabled = YES;
// タッチイベント処理オーバーライドメソッド
-(BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event{}
-(void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event{}
-(void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event{}
-(void)ccTouchCancelled:(UITouch *)touch withEvent:(UIEvent *)event{}
// タッチ開始処理
-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// タッチ位置取得&変換
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView: [touch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
}
// タッチイベント有効化
self.userInteractionEnabled = YES;
// タッチイベント処理オーバーライドメソッド
-(void)touchBegan:(UITouch *)touch withEvent:(UIEvent *)event{}
-(void)touchMoved:(UITouch *)touch withEvent:(UIEvent *)event{}
-(void)touchEnded:(UITouch *)touch withEvent:(UIEvent *)event{}
-(void)touchCancelled:(UITouch *)touch withEvent:(UIEvent *)event{}
// タッチ開始処理
- (void)touchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
// タッチ位置取得
CGPoint location = [touch locationInNode:self];
}
<所感>
- SpriteBuilder開発ツール採用による影響と推測していますが、CCLayerクラスを消しちゃうなんて思い切った事を判断をしたものだと関心します。(^^ゞ
- CCLayerを機能拡張しているクラスとかどうすんだろって思いますよね〜!?
└ CCScrollLayer,CCTMXLayerとか。。。
ではまた〜
0 件のコメント:
コメントを投稿