Cocos2d-x 3.2 Lua example CurrentLanguageTest (current language environment)

Source: Internet
Author: User

Cocos2d-x 3.2 Lua example CurrentLanguageTest (current language environment)

Cocos2d-x 3.2 Lua example CurrentLanguageTest (current language environment)


Reprinted Please note: IT_xiao xiaowu

This blog introduces an example provided by Cocos2d-x 3.2 to obtain the language environment of the current program, which can be achieved through the following methods:

 local currentLanguageType = cc.Application:getInstance():getCurrentLanguage()


Example:


Sample Code: <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD48cD48cHJlIGNsYXNzPQ = "brush: java;"> -- [[======================== currentcancagetest. lua current language environment test =========================]] -- local function current1_agetest () local ret = cc. layer: create () -- create Layer local label = cc. label: createWithTTF ("Current language Test", s_arialPath, 28) -- label ret: addChild (label, 0) -- add sub-node Label: setAnchorPoint (cc. p (0.5, 0.5) -- set the anchor label: setPosition (cc. p (VisibleRect: center (). x, VisibleRect: top (). y-50) -- set location local labelLanguage = cc. label: createWithTTF ("", s_arialPath, 20) -- display Language Label labelLanguage: setAnchorPoint (cc. p (0.5, 0.5) -- set the anchor labelLanguage: setPosition (VisibleRect: center () -- set the location. For details about VisibleRect, see VisibleRect. lua file -- Obtain the current language environment of the system application. local current1_agetype = cc. application: getInstance (): getCurrentLanguage () -- English if current1_agetype = cc. export age_english then labelLanguage: setString ("current language is English") elseif current1_agetype = cc. export age_chinese then -- Chinese labelLanguage: setString ("current language is Chinese") elseif current1_agetype = cc. export age_french then -- French labelLanguage: setString ("current language is French") elseif current1_agetype = cc. export age_german then labelLanguage: setString ("current language is German") -- German elseif current1_agetype = cc. export age_italian then labelLanguage: setString ("current language is Italian") elseif current1_agetype = cc. export age_russian then -- Russian labelLanguage: setString ("current language is Russian") elseif current1_agetype = cc. export age_spanish then -- labelLanguage in Spanish: setString ("current language is Spanish") elseif current1_agetype = cc. export age_korean then -- Korean labelLanguage: setString ("current language is Korean") elseif current1_agetype = cc. export age_japanese then -- labelLanguage: setString ("current language is Japanese") elseif current1_agetype = cc. export age_hungarian then -- labelLanguage in Hungary: setString ("current language is Hungarian") elseif current1_agetype = cc. export age_portuguese then -- labelLanguage in Portugal: setString ("current language is Portuguese") elseif current1_agetype = cc. export age_arabic then -- Arabic labelLanguage: setString ("current language is Arabic") end ret: addChild (labelLanguage) return retend -- test method function current1_agetestmain () local scene = cc. scene: create () -- create scenario local pLayer = currentequalagetest () -- layer scene: addChild (pLayer) -- add layer to scenario scene: addChild (CreateBackMenuItem () return sceneend


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.