gameStateInit.lua 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. local gameStateInit = class('gameStateInit')
  2. local designSize = cc.size( 1136, 640 )
  3. local SplashTime = 1.0
  4. local SplashFadeInTime = 0.6
  5. local SplashFadeOutTime = 0.8
  6. function gameStateInit:ctor()
  7. self._currScene = nil
  8. end
  9. function gameStateInit:getStateType()
  10. return global.MMO.GAME_STATE_INIT
  11. end
  12. function gameStateInit:onEnter()
  13. -- reset FPS
  14. global.Director:setAnimationInterval( 1 / 60 )
  15. self:InitController()
  16. self:InitDownloader()
  17. self:InitModel()
  18. self:InitMediator()
  19. self:InitDebug()
  20. --init randomseed
  21. math.randomseed( tonumber(tostring(os.time()):reverse():sub(1,6)) )
  22. -- splash and goto login
  23. self:InitSplash()
  24. if global.isWinPlayMode then
  25. setCusTomCursor(global.MMO.CURSOR_TYPE_NORMAL)
  26. end
  27. return 1
  28. end
  29. function gameStateInit:onEnd()
  30. return 1
  31. end
  32. function gameStateInit:onExit()
  33. return 1
  34. end
  35. function gameStateInit:InitModel()
  36. local facade = global.Facade
  37. -- string_table
  38. local StringTable = requireProxy( "local/StringTableProxy" )
  39. local stringTableInst = StringTable.new( global.ProxyTable.StringTable )
  40. facade:registerProxy( stringTableInst )
  41. -- color style
  42. local ColorStyleProxy = requireProxy("local/ColorStyleProxy")
  43. facade:registerProxy( ColorStyleProxy.new() )
  44. -- login proxy
  45. local LoginProxy = requireProxy( "remote/LoginProxy" )
  46. facade:registerProxy( LoginProxy.new() )
  47. -- Auth Proxy
  48. local AuthProxy = requireProxy( "remote/AuthProxy" )
  49. facade:registerProxy( AuthProxy.new() )
  50. -- 敏感词
  51. local SensitiveWordProxy = requireProxy( "local/SensitiveWordProxy" )
  52. facade:registerProxy( SensitiveWordProxy.new() )
  53. -- audio
  54. local AudioProxy = requireProxy("local/AudioProxy")
  55. facade:registerProxy( AudioProxy.new() )
  56. -- model config proxy
  57. local ModelConfigProxy = requireProxy("local/ModelConfigProxy")
  58. facade:registerProxy( ModelConfigProxy.new() )
  59. -- NativeBridgeProxy
  60. local NativeBridgeProxy = requireProxy( "local/NativeBridgeProxy" )
  61. facade:registerProxy( NativeBridgeProxy.new() )
  62. -- local revcData = global.L_NativeBridgeManager._revcData
  63. -- if revcData and revcData.otherTradingBank and tostring(revcData.otherTradingBank) == "1" then
  64. -- global.OtherTradingBank = true -- 联运 交易行
  65. -- end
  66. local currentModule = global.L_ModuleManager:GetCurrentModule()
  67. local moduleGameEnv = currentModule:GetGameEnv()
  68. local exchangeIsTrade = moduleGameEnv:GetCustomDataByKey("exchangeIsTrade")
  69. dump(exchangeIsTrade,"exchangeIsTrade_____")
  70. if exchangeIsTrade and exchangeIsTrade == 1 then
  71. global.OtherTradingBank = true -- 联运 交易行
  72. end
  73. --TradingBankProxy
  74. local TradingBankProxy = requireProxy( "remote/TradingBankProxy" )
  75. facade:registerProxy( TradingBankProxy.new() )
  76. local OtherTradingBankProxy = requireProxy( "remote/OtherTradingBankProxy" )
  77. facade:registerProxy( OtherTradingBankProxy.new() )
  78. --VerificationProxy
  79. local VerificationProxy = requireProxy( "remote/VerificationProxy" )
  80. facade:registerProxy( VerificationProxy.new() )
  81. --SUIComponentProxy
  82. local SUIComponentProxy = requireProxy( "remote/SUIComponentProxy" )
  83. facade:registerProxy( SUIComponentProxy.new() )
  84. -- MetaValueProxy
  85. local MetaValueProxy = requireProxy( "remote/MetaValueProxy" )
  86. facade:registerProxy( MetaValueProxy.new() )
  87. -- ConditionProxy
  88. local ConditionProxy = requireProxy( "remote/ConditionProxy" )
  89. facade:registerProxy( ConditionProxy.new() )
  90. --Data RePort
  91. local DataRePortProxy = requireProxy( "local/DataRePortProxy" )
  92. facade:registerProxy( DataRePortProxy.new() )
  93. -- DataTrackProxy
  94. local DataTrackProxy = requireProxy( "local/DataTrackProxy" )
  95. facade:registerProxy( DataTrackProxy.new() )
  96. -- login otp
  97. local LoginOtpPassWordProxy = requireProxy("remote/LoginOtpPassWordProxy")
  98. facade:registerProxy( LoginOtpPassWordProxy.new() )
  99. end
  100. function gameStateInit:InitController()
  101. local facade = global.Facade
  102. -- http download
  103. if not global.HttpDownloader then
  104. global.HttpDownloader = httpDownloader:Inst()
  105. end
  106. -- environment
  107. if not global.gameEnvironment then
  108. global.gameEnvironment = gameEnviroment:Inst()
  109. end
  110. -- netClient
  111. local aNetClient = global.gameEnvironment:GetNetClient()
  112. if aNetClient then
  113. if aNetClient.ResetDecoder then
  114. aNetClient:ResetDecoder()
  115. end
  116. else
  117. aNetClient = netClient:new()
  118. global.gameEnvironment:SetNetClient( aNetClient )
  119. end
  120. if not global.networkCtl then
  121. global.networkCtl = LuaNetworkController:Inst()
  122. global.networkCtl:SetNetClientPtr( aNetClient )
  123. end
  124. -- LuaBridgeCtl
  125. if not global.LuaBridgeCtl then
  126. global.LuaBridgeCtl = LuaBridgeCtl:Inst()
  127. end
  128. -- FrameAnimManager
  129. if not global.FrameAnimManager then
  130. local actorSequFrameAnimManager = require( "animation/actorSequFrameAnimManager" )
  131. global.FrameAnimManager = actorSequFrameAnimManager.new()
  132. end
  133. -- CustomCache
  134. if not global.CustomCache then
  135. local CustomCache = requireUtil("CustomCache")
  136. global.CustomCache = CustomCache.new()
  137. end
  138. -- SUIManager
  139. if not global.SUIManager then
  140. local SUIManager = require( "sui/SUIManager" )
  141. global.SUIManager = SUIManager:Inst()
  142. end
  143. -- SWidgetCache
  144. if not global.SWidgetCache then
  145. local SWidgetCache = require( "sui/SWidgetCache" )
  146. global.SWidgetCache = SWidgetCache.new()
  147. end
  148. -- mod bridge
  149. if not global.modBridgeController then
  150. global.modBridgeController = require("logic/ModBridgeController").new()
  151. end
  152. local cmd = requireCommand( "gamestates/LoadingCompletedCommand" )
  153. facade:registerCommand( global.NoticeTable.LoadingCompleted, cmd )
  154. local cmd = requireCommand( "gamestates/LoadingBeginCommand" )
  155. facade:registerCommand( global.NoticeTable.LoadingBegin, cmd )
  156. local GameWorldConfirmCommand = requireCommand( "gamestates/GameWorldConfirmCommand" )
  157. facade:registerCommand(global.NoticeTable.GameWorldConfirm, GameWorldConfirmCommand)
  158. local GameWorldInfoInitCommand = requireCommand( "gamestates/GameWorldInfoInitCommand" )
  159. facade:registerCommand(global.NoticeTable.GameWorldInfoInit, GameWorldInfoInitCommand)
  160. -- shader
  161. local GrayShaderCmd = requireCommand( "shader/GrayShaderCommand" )
  162. local NormalShaderCmd = requireCommand( "shader/NormalShaderCommand" )
  163. facade:registerCommand( global.NoticeTable.GrayNodeShader, GrayShaderCmd )
  164. facade:registerCommand( global.NoticeTable.NormalNodeShader, NormalShaderCmd )
  165. -- pc view name
  166. local AppViewNameChangeCommand = requireCommand( "other/AppViewNameChangeCommand" )
  167. facade:registerCommand(global.NoticeTable.AppViewNameChange, AppViewNameChangeCommand)
  168. end
  169. function gameStateInit:InitDownloader()
  170. -- HttpDownloader
  171. local module = global.L_ModuleManager:GetCurrentModule()
  172. local modulePath = module.GetSubModPath and module:GetSubModPath() or module:GetStabPath()
  173. local moduleGameEnv = module:GetGameEnv()
  174. local rootDomain = moduleGameEnv:GetSceneDownloadUrl()
  175. local resVersionOri = moduleGameEnv.GetSceneDownloadVer and moduleGameEnv:GetSceneDownloadVer() or moduleGameEnv:GetResVersion()
  176. local storagePath = cc.FileUtils:getInstance():getWritablePath() .. modulePath
  177. local subMod = module:GetCurrentSubMod()
  178. local subModInfo = subMod:GetSubModInfo()
  179. local gameid = subMod:GetOperID()
  180. local xk = subMod:GetXK()
  181. local channelID = global.L_GameEnvManager:GetChannelID() or 1
  182. local resVersion = resVersionOri
  183. if GetCdnSign then
  184. local sign = GetCdnSign(gameid, global.modListSrvTime, xk or "")
  185. local param = string.format("gameId=%s&time=%s&sign=%s&channelID=%s", gameid, global.modListSrvTime, sign, channelID)
  186. resVersion = string.format("%s&%s", resVersionOri, param)
  187. --刷新时间戳 cdn鉴权
  188. global.modListSrvTimeCallFuncs = {}
  189. local refResTime = function ()
  190. local sign = GetCdnSign(gameid, global.modListSrvTime, xk or "")
  191. local param = string.format("gameId=%s&time=%s&sign=%s&channelID=%s", gameid, global.modListSrvTime, sign, channelID)
  192. local resVersion = string.format("%s&%s", resVersionOri, param)
  193. global.HttpDownloader:SetResourceVer(resVersion)
  194. end
  195. table.insert(global.modListSrvTimeCallFuncs, refResTime)
  196. end
  197. global.HttpDownloader:SetTimeOut(30)
  198. global.HttpDownloader:SetSpeedLimit(0)
  199. global.HttpDownloader:SetResourceVer(resVersion)
  200. global.HttpDownloader:SetDownloadURL(rootDomain)
  201. global.HttpDownloader:SetDownloadDir(storagePath)
  202. global.HttpDownloader:SetDownloadProgress(nil)
  203. -- 文件夹创建
  204. if not global.FileUtilCtl:isDirectoryExist(storagePath) then
  205. global.FileUtilCtl:createDirectory(storagePath)
  206. end
  207. local stabPath = cc.FileUtils:getInstance():getWritablePath() .. module:GetStabPath()
  208. if not global.FileUtilCtl:isDirectoryExist(stabPath) then
  209. global.FileUtilCtl:createDirectory(stabPath)
  210. end
  211. local items =
  212. {
  213. "anim/",
  214. "anim/effect/",
  215. "anim/hair/",
  216. "anim/monster/",
  217. "anim/npc/",
  218. "anim/player/",
  219. "anim/weapon/",
  220. "anim/shield/",
  221. "anim/wings/",
  222. "mp3/",
  223. "scene/",
  224. "scene/map/",
  225. "scene/objects/",
  226. "scene/smtiles/",
  227. "scene/tiles/",
  228. "scene/uiminimap/",
  229. }
  230. for _, v in ipairs(items) do
  231. local path = storagePath .. v
  232. if not global.FileUtilCtl:isDirectoryExist(path) then
  233. global.FileUtilCtl:createDirectory(path)
  234. end
  235. local path = stabPath .. v
  236. if not global.FileUtilCtl:isDirectoryExist(path) then
  237. global.FileUtilCtl:createDirectory(path)
  238. end
  239. end
  240. -- dev
  241. if global.isWindows and (global.isDebugMode or global.isGMMode) then
  242. local items =
  243. {
  244. "res",
  245. "res/buff_icon",
  246. "res/custom",
  247. "res/item",
  248. "res/item_ground",
  249. "res/player_show",
  250. "res/skill_icon",
  251. "res/skill_icon_c",
  252. "res/Topwear",
  253. "res/private",
  254. "res/public",
  255. "anim",
  256. "anim/effect",
  257. "anim/hair",
  258. "anim/monster",
  259. "anim/npc",
  260. "anim/player",
  261. "anim/weapon",
  262. "anim/shield/",
  263. "anim/wings/",
  264. "mp3",
  265. "scene",
  266. "scene/map",
  267. "scene/objects",
  268. "scene/smtiles",
  269. "scene/tiles",
  270. "scene/uiminimap",
  271. "data_config",
  272. "data_config/ui_config",
  273. "scripts",
  274. "scripts/game_config",
  275. "GUILayout",
  276. "GUIExport",
  277. "GUIValue",
  278. ".996",
  279. "fonts",
  280. }
  281. local devPath = global.FileUtilCtl:getDefaultResourceRootPath() .. "dev"
  282. for _, v in ipairs(items) do
  283. local path = devPath .. "/" .. v
  284. if not global.FileUtilCtl:isDirectoryExist(path) then
  285. global.FileUtilCtl:createDirectory(path)
  286. end
  287. end
  288. -- fix configs
  289. local fixPath = devPath .. "/data_config/msg_decoder_config.txt"
  290. if global.FileUtilCtl:isFileExist(fixPath) then
  291. local fullPath = global.FileUtilCtl:fullPathForFilename(fixPath)
  292. global.FileUtilCtl:removeFile( fixPath )
  293. global.FileUtilCtl:purgeCachedEntries()
  294. end
  295. end
  296. -- GM网络资源 边玩边下
  297. global.ResDownloader = require("assets_downloader/ResDownloader").new()
  298. global.ResDownloader:init()
  299. end
  300. function gameStateInit:InitMediator()
  301. local facade = global.Facade
  302. -- scene
  303. local scene = cc.Scene:create()
  304. local currScene = global.Director:getRunningScene()
  305. if not currScene then
  306. global.Director:runWithScene( scene )
  307. else
  308. global.Director:replaceScene( scene )
  309. end
  310. self._currScene = scene
  311. if not global.mouseEventController then
  312. local mouseEventController = require( "logic/mouseEventController" )
  313. global.mouseEventController = mouseEventController:Inst()
  314. end
  315. -- register audio mgr
  316. local AudioMediator = requireMediator( "audio/AudioMediator" )
  317. local audioMediator = AudioMediator.new()
  318. facade:registerMediator( audioMediator )
  319. -- rigister layer facade
  320. local LayerFacadeMediator = requireMediator( "LayerFacadeMediator" )
  321. local lFMediator = LayerFacadeMediator.new()
  322. lFMediator:InitOnEnterActive( scene )
  323. facade:registerMediator( lFMediator )
  324. local NoticeProxy = requireProxy( "remote/NoticeProxy" )
  325. local noticeProxy = NoticeProxy.new()
  326. facade:registerProxy( noticeProxy )
  327. -- notice
  328. local MediatorClass = requireMediator( "message_layer/NoticeMediator" )
  329. local mediator = MediatorClass.new()
  330. facade:registerMediator( mediator )
  331. -- loadingbar layer
  332. local LoadingBarMediator = requireMediator( "loading_layer/LoadingBarMediator" )
  333. local loadingBarMediator = LoadingBarMediator.new()
  334. facade:registerMediator( loadingBarMediator )
  335. -- commonTips
  336. local MediatorClass = requireMediator( "common_tips_layer/CommonTipsMediator" )
  337. local mediator = MediatorClass.new()
  338. facade:registerMediator( mediator )
  339. local Mediator = requireMediator("common_tips_layer/CommonDescTipsMediator")
  340. global.Facade:registerMediator(Mediator.new())
  341. --
  342. local GameWorldConfirmMediator = requireMediator("game_world_confirm_layer/GameWorldConfirmMediator")
  343. facade:registerMediator(GameWorldConfirmMediator.new())
  344. -- login
  345. local LoginAccountMediator = requireMediator("login_layer/LoginAccountMediator")
  346. local loginServerMediator = requireMediator("login_layer/LoginServerMediator")
  347. local loginRoleMediator = requireMediator("login_layer/LoginRoleMediator")
  348. local loginRoleLockMediator = requireMediator("login_layer/LoginRoleLockMediator")
  349. local loginVersionMediator = requireMediator("login_layer/LoginVersionMediator")
  350. facade:registerMediator(LoginAccountMediator.new())
  351. facade:registerMediator(loginServerMediator.new())
  352. facade:registerMediator(loginRoleMediator.new())
  353. facade:registerMediator(loginRoleLockMediator.new())
  354. facade:registerMediator(loginVersionMediator.new())
  355. --
  356. local UserInputController = require("logic/UserInputController")
  357. global.userInputController = UserInputController:Inst()
  358. local Mediator = requireMediator( "trading_bank_layer/TradingBankPhoneLayerMediator" )
  359. global.Facade:registerMediator( Mediator.new() )
  360. local Mediator = requireMediator( "trading_bank_layer/TradingBankTipsLayerMediator" )
  361. global.Facade:registerMediator( Mediator.new() )
  362. local Mediator = requireMediator( "trading_bank_layer/TradingBankTips2LayerMediator" )
  363. global.Facade:registerMediator( Mediator.new() )
  364. -------------------三方交易行
  365. local Mediator = requireMediator( "trading_bank_layer_other/TradingBankPhoneLayerMediator_other" )
  366. global.Facade:registerMediator( Mediator.new() )
  367. local Mediator = requireMediator( "trading_bank_layer_other/TradingBankTipsLayerMediator_other" )
  368. global.Facade:registerMediator( Mediator.new() )
  369. local Mediator = requireMediator( "trading_bank_layer_other/TradingBankTips2LayerMediator_other" )
  370. global.Facade:registerMediator( Mediator.new() )
  371. local Mediator = requireMediator( "common_tips_layer/CommonVerificationMediator" )
  372. global.Facade:registerMediator( Mediator.new() )
  373. local Mediator = requireMediator( "common_tips_layer/CommonLimitVerificationMediator" )
  374. global.Facade:registerMediator( Mediator.new() )
  375. -- delay exit game
  376. local Mediator = requireMediator( "delay_exit_game/DelayExitGameMediator" )
  377. global.Facade:registerMediator( Mediator.new() )
  378. -- login top
  379. local Mediator = requireMediator( "login_layer/LoginOtpPassWordMediator" )
  380. global.Facade:registerMediator( Mediator.new() )
  381. end
  382. function gameStateInit:InitDebug()
  383. -- for debug anim
  384. if global.isDebugMode or global.isGMMode then
  385. local Mediator = requireMediator( "test_layer/PreviewAnimMediator" ).new()
  386. global.Facade:registerMediator( Mediator )
  387. end
  388. if global.isDebugMode or global.isGMMode then
  389. local Mediator = requireMediator( "test_layer/AnimSetMediator" ).new()
  390. global.Facade:registerMediator( Mediator )
  391. end
  392. -- sui
  393. if global.isDebugMode or global.isGMMode then
  394. local Mediator = requireMediator( "test_layer/SUIEditorMediator" ).new()
  395. global.Facade:registerMediator( Mediator )
  396. end
  397. -- cui
  398. if global.isDebugMode or global.isGMMode then
  399. local Mediator = requireMediator( "test_layer/CUIEditorMediator" ).new()
  400. global.Facade:registerMediator( Mediator )
  401. end
  402. if global.isDebugMode or global.isGMMode then
  403. local Mediator = requireMediator( "test_layer/PreviewSkillMediator" ).new()
  404. global.Facade:registerMediator( Mediator )
  405. end
  406. if global.isDebugMode or global.isGMMode then
  407. local Mediator = requireMediator( "test_layer/ConfigSettingMediator" ).new()
  408. global.Facade:registerMediator( Mediator )
  409. end
  410. if global.isDebugMode or global.isGMMode then
  411. local Mediator = requireMediator( "test_layer/PreviewAnimActionMediator" ).new()
  412. global.Facade:registerMediator( Mediator )
  413. end
  414. if global.isDebugMode or global.isGMMode then
  415. local Mediator = requireMediator( "test_layer/MagicInfoConfigMediator" ).new()
  416. global.Facade:registerMediator( Mediator )
  417. end
  418. if global.isDebugMode or global.isGMMode then
  419. local Mediator = requireMediator( "test_layer/PreviewNodeMediator" )
  420. global.Facade:registerMediator( Mediator.new() )
  421. end
  422. -- gui
  423. if global.isDebugMode or global.isGMMode then
  424. local Mediator = requireMediator( "gui_layer/GUIEditorMediator" ).new()
  425. global.Facade:registerMediator( Mediator )
  426. local Mediator = requireMediator( "gui_layer/GUITXTEditorMediator" ).new()
  427. global.Facade:registerMediator( Mediator )
  428. local Mediator = requireMediator( "gui_layer/GUITXTEditorEventMediator" ).new()
  429. global.Facade:registerMediator( Mediator )
  430. end
  431. -- gui res selector
  432. if global.isDebugMode or global.isGMMode then
  433. local Mediator = requireMediator( "gui_layer/GUIResSelectorMediator" ).new()
  434. global.Facade:registerMediator( Mediator )
  435. end
  436. if global.isDebugMode or global.isGMMode then
  437. local Mediator = requireMediator("gui_layer/ExtraColorEditorMediator").new()
  438. global.Facade:registerMediator(Mediator)
  439. end
  440. -- gui color selector
  441. if global.isDebugMode or global.isGMMode then
  442. local Mediator = requireMediator( "gui_layer/GUIColorSelectorMediator" ).new()
  443. global.Facade:registerMediator( Mediator )
  444. end
  445. -- gui var manager
  446. if global.isDebugMode or global.isGMMode then
  447. local Mediator = requireMediator( "gui_layer/GUIVarManagerMediator" ).new()
  448. global.Facade:registerMediator( Mediator )
  449. end
  450. end
  451. function gameStateInit:InitSplash()
  452. local function finishCB()
  453. global.Facade:sendNotification( global.NoticeTable.ChangeGameState, global.MMO.GAME_STATE_LOGIN )
  454. end
  455. -- 本次游戏只闪一次
  456. -- record splash switch
  457. if global.LuaBridgeCtl:GetModulesSwitch(global.MMO.Modules_Index_Enable_Splash) == 1 then
  458. finishCB()
  459. return
  460. end
  461. global.LuaBridgeCtl:SetModulesSwitch(global.MMO.Modules_Index_Enable_Splash, 1)
  462. -- 闪屏配置
  463. local splash =
  464. {
  465. {filename = "splash.png"},
  466. }
  467. -- 未配置
  468. if not splash or not next(splash) then
  469. finishCB()
  470. return
  471. end
  472. -- show
  473. local items = clone(splash)
  474. local function showSplashAuto()
  475. if #items <= 0 then
  476. finishCB()
  477. return
  478. end
  479. local item = table.remove(items, 1)
  480. local filename = item.filename
  481. -- config error
  482. if not filename or "" == filename then
  483. showSplashAuto()
  484. return
  485. end
  486. -- check file exist
  487. local splashPath = global.MMO.PATH_RES_PRIVATE .. "splash/" .. filename
  488. if not global.FileUtilCtl:isFileExist( splashPath ) then
  489. showSplashAuto()
  490. return
  491. end
  492. -- image
  493. local origin = global.Director:getVisibleOrigin()
  494. local viewSize = global.Director:getVisibleSize()
  495. local image = ccui.ImageView:create()
  496. image:loadTexture( splashPath )
  497. image:setPosition( viewSize.width * 0.5, viewSize.height * 0.5 )
  498. image:setAnchorPoint( 0.5, 0.5 )
  499. self._currScene:addChild( image )
  500. local function callback()
  501. showSplashAuto()
  502. end
  503. image:setOpacity( 0 )
  504. image:runAction( cc.Sequence:create(
  505. cc.FadeIn:create( SplashFadeInTime ),
  506. cc.DelayTime:create( SplashTime ),
  507. cc.FadeTo:create( SplashFadeOutTime, 20 ),
  508. cc.CallFunc:create( callback ),
  509. cc.RemoveSelf:create()
  510. ) )
  511. -- remove texture cache
  512. global.TextureCache:removeTextureForKey( splashPath )
  513. end
  514. showSplashAuto()
  515. end
  516. return gameStateInit