日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Cocos2D将v1.0的tileMap游戏转换到v3.4中一例(八)

發布時間:2023/11/29 编程问答 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Cocos2D将v1.0的tileMap游戏转换到v3.4中一例(八) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

大熊貓豬·侯佩原創或翻譯作品.歡迎轉載,轉載請注明出處.
如果覺得寫的不好請告訴我,如果覺得不錯請多多支持點贊.謝謝! hopy ;)


回到Xcode中,新建一個EndLayer類,繼承于CCNode.因為我們得在其類方法中創建實例變量,所以我們得建立幾個實例變量的屬性.打開EndLayer.h文件,修改內容如下:

#import "CCNode.h"@class MainScene;@interface EndLayer : CCNode@property (nonatomic,strong) CCLabelBMFont *msgLabel; @property (nonatomic,strong) CCLabelBMFont *restartLabel; @property (nonatomic,weak) MainScene *mainScene;+(instancetype)endLayerWithMainScene:(MainScene*)mainScene message:(NSString*)msg;@end

接著打開EndLayer.m文件添加如下代碼:

#import "EndLayer.h" #import "MainScene.h"@implementation EndLayer-(void)restartTapped:(id)sender{CCScene *scene = [CCBReader loadAsScene:@"MainScene"];CCTransition *transition = [CCTransition transitionFadeWithColor:[CCColor whiteColor] duration:0.5];[[CCDirector sharedDirector]replaceScene:scene withTransition:transition]; }-(void)onEnter{[super onEnter];[self.msgLabel runAction:[CCActionScaleTo actionWithDuration:0.5 scale:1.0]];[self.restartLabel runAction:[CCActionScaleTo actionWithDuration:0.5 scale:1.0]]; }+(instancetype)endLayerWithMainScene:(MainScene*)mainScene message:(NSString*)msg{EndLayer *endLayer = (EndLayer*)[CCBReader load:@"EndLayer"];endLayer.mainScene = mainScene;endLayer.msgLabel.string = msg;endLayer.msgLabel.scale = 0.1;endLayer.restartLabel.scale = 0.1;return endLayer; }@end

注意我們在其onEnter方法中實現了原代碼中的菜單動畫效果,現在編譯運行app,效果如下:

OK!至此我們全部完成了原代碼的轉換工作,該系列8篇博文到此告一段落.

本貓豬將在新開辟博文”A*尋路算法的Cocos2D實現”的系列文章中,繼續CatMazeV3項目的擴展旅程,敬請期待,再會! ;)

總結

以上是生活随笔為你收集整理的Cocos2D将v1.0的tileMap游戏转换到v3.4中一例(八)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。