Total Pageviews

Thursday, April 17, 2014

composer.loadScene() vs composer.newScene()


composer.loadScene()
ប្រើសំរាប់ loads នៅ scene ណាមួយ, តាមពិតវាលាក់ខ្លួននៅខាងក្រោយ current scene​ ដោយមិនមាន initiating a scene transition។ សំរាប់ហ្វាំងសិននេះដូចគ្នានឹង composer.gotoScene() ប៉ុន្តែវាមិនប្តូរនៅ currently active scene។ វាគ្រាន់តែបង្តើត create event ដែលត្រូវ dispatched ទៅលើ scene ដែលសន្មត់ថា self.view មិនទាន់មាន។ ជាមួយនឹងការបន្ថែមវាអាចបញ្ចូលនៅ doNotLoadView flag នៅពេលហៅ ហ្វាំងសិននេះ។ ការធ្វើដូចនេះវាគ្រាន់តែ load scene’s object មិនមែនជា self.view display group។ ហ្វាំងសិននេះត្រូវបានប្រើជាមួយនឹង pre-load a scene មុនពេលចាប់ផ្តើម transition on it, ដែលនឹងចាប់ផ្តើមនៅពេលក្រោយ
Syntax: composer.loadScene ( sceneName [, doNotLoadView] [, params] )
sceneName(តំរូវការ) វាជា string ដែលជាឈ្មោះរបស់ scene ត្រូវ load, វាលាក់ខ្លួននៅក្រោយ current scene
doNotLoadView(ជំរើស) វាជា Boolean ដែលត្រូវបញ្ចូលទៅជា​true ក្នុងការ load only scene’s object មិនមែនជា self.view display group។ ពេលនោះវានឹង create event ដែលត្រូវ dispatched នៅលើ scene ដែលសន្មត់ថា self.view មិនទាន់មាន
params(ជំរើស) វាជាតារាងដែលជាជំរើស table containing any kind of custom data ដែលត្រូវ transferred ទៅកាន់ scene។ នៅ scene ច្បាស់លាស់ដែលទិន្នន័យនេះអាច accessed បានតាមរយះ event.params នៅក្នុង create event, unless doNotLoadView ត្រូវបញ្ចូលជា true

សូមមើលកូដះ
local composer = require( "composer" )
local currentScore = 200
-- Pre-load the scene, hidden behind the current scene
local options = { level="Level 1", score=currentScore }
local results = composer.loadScene( "results", false, options )

-- Later, transition to the hidden scene (no loading necessary)
composer.gotoScene( "results", "fade", 800 )

composer.newScene()
នេះជាហ្វាំងសិនដែលប្រើសំរាប់បង្កើតនៅ new scene objects ដែលអាចប្រើជាមួយនឹង Composer Library
Syntax: composer.newScene()

No comments:

Post a Comment