Total Pageviews

Monday, March 17, 2014

Library Display របស់ Corona SDK


វាមានតួនាទីសំរាប់បង្ហាញអ្វីមួយនៅលើ Smart Devices របស់អ្នកប្រើប្រាស់។ វាមាន Properties យ៉ាងសំបូរបែបអាចប្រើតាមតំរូវការបានយ៉ាងងាយ។  ចូរមើល Properties របស់វាតាមលំដាប់លំដោយះ
Display.actualContentHeight Vs Display.actualContentWidth (កំពស់ & បណ្តោយ) វាមានតួនាទីសំរាប់បង្ហាញ Height របស់ Corona នៅក្នុងអេក្រង។ លទ្ធផលអាស្រ័យទៅលើ Scale ដែលត្រូវបន្ថែមកូដនៅក្នុង Config.lua វាមានតួនាទីដូចខាងក្រោមះ
* for zoomEven scale ដែលតំលៃរបស់វាត្រូវនឹង display.viewableContentHeight
* for zoomStretch scale សំរាប់ content height
* for letterbox scale សំរាប់ content height, រួមទាំង letterbox area
Code:
(សូម Copy កូដខាងក្រោមរួច ដាក់លើ Editors ណាមួយបន្ទាប់មក à save ជា(main.lua))
_W = display.contentWidth
_H = display.contentHeight
local sync = display.newImage ("sync.png", 225, 255)
sync.x = _W/2; sync.y = (_H/2) - 200
print( display.actualContentHeight )
-- adding the text to display the size
local showHeight = display.newText ("Your smart device Height is: " .. display.actualContentHeight, 100, 200, native.systemFont, 34)
showHeight:setFillColor (1,0,0.5)
showHeight.x = 350; showHeight.y = 500
--adding the show width of the devices
local showWidth = display.newText ("Your smart device Width is: " .. display.actualContentWidth, 100, 200, native.systemFont, 34)
showWidth:setFillColor (0,0,0.5)

showWidth.x = 350; showWidth.y = 600

No comments:

Post a Comment