Total Pageviews

Wednesday, April 30, 2014

composer.gotoScene()

composer.gotoScene()
នេះជាហ្វាំងសិនដែលប្រើសំរាប់ transition ទៅកាន់ Scene ណាមួយ។ នៅពេលហៅវាមកប្រើពេលនោះ hide event ត្រូវបាន dispatched ទៅកាន់ current scene (បើសិនជា Scene វាមានរួចហើយ)។ បើសិនជា self.view group មិនមានសំរាប់ក្រុមណាមួយ, the create event នឹង dispatched ទៅកាន់ Scene នោះ។ ពេលនោះ show event នឹងត្រូវ dispatched
Syntax: composer.gotoScene (sceneName [, options] )
sceneName(តំរូវការ) វាជា String ដែលជាឈ្មោះរបស់ Scene ក្នុងការទៅកាន់ Next Scene។ នៅក្នុងករណីជាច្រើន, វាជាឈ្មោះរបស់ scene’s Lua file (ដោយមិនមាន .lua exntension)
options(ជំរើស) វាជា table ដែលផ្ទុកនៅ several transition ដែលទាក់ទង់នឹង Options ដូចជា effect type, custom parameters, ឧះ សូមមើល Scene Options សំរាប់ format នៃ Table នេះ

Scene Options:
សំរាប់ជំរើស Options table អាចផ្ទុកនៅជំរើសផ្សេងៗសំរាប់ target scene:
Local options = { effect = “fade”, time = 400, params = { sampleVar1 = “my sample”, sampleVar2 = “more sample” } }
Effect(ជំរើស) វាជា String ដែលជាការ transition នៅ specific scene ណាមួយ។ សូមមើល transition effects សំរាប់ជំរើសផ្សេងៗ។ បើសិនជា scene មិនត្រូវបានដាក់ឪ្យប្រើច្បាស់លាស់ពេលនោះ scene transition នឹងបន្ត instantaneously
Time(ជំរើស) វាជាចំនួនលេខដែលប្រើជា time duration សំរាប់ effect, តំលៃដើមគឺ 500 miliseconds
Params(ជំរើស) វាជាតារាងដែលជាជំរើសរបស់តារាងដែលផ្ទុកនៅ custom data ដែលត្រូវ transferred ទៅកាន់ Scene។ វាអាច accessed បានតាមរយះ event.params នៅក្នុង create event or show event
 Transition effects:
ខាងក្រោមនេះជា String values ត្រូវបាន supported សំរាប់ ​effect key នៃ Option របស់ table:
•"fade"
 •"crossFade"
 •"zoomOutIn"
 •"zoomOutInFade"
 •"zoomInOut"
 •"zoomInOutFade"
 •"flip"
 •"flipFadeOutIn"
 •"zoomOutInRotate"
 •"zoomOutInFadeRotate"
 •"zoomInOutRotate"
 •"zoomInOutFadeRotate"
 •"fromRight" — over current scene
 •"fromLeft" — over current scene
 •"fromTop" — over current scene
 •"fromBottom" — over current scene
 •"slideLeft" — pushes current scene off
 •"slideRight" — pushes current scene off
 •"slideDown" — pushes current scene off
 •"slideUp" — pushes current scene off

សូមមើលកូដះGoing to another scene

local composer = require( "composer" )
local currentScore = 200
-- Later...
local options = {
    effect = "fade",
    time = 800,
    params = { level="Level 1", score=currentScore }
}
composer.gotoScene( "results", options )

Reloading the Current Scene
 local composer = require( "composer" )

-- Later...
local currScene = composer.getSceneName( "current" )
composer.gotoScene( currScene )


No comments:

Post a Comment