Total Pageviews

Tuesday, June 3, 2014

នេះជា Type Web View របស់ Corona SDK

នេះជា Type Web View របស់ Corona SDK
វាជា Web View object ដែលជា native display object។ វាអាច move & rotate it ឬអាចបន្ថែមនៅ physics body
នេះជា Properties របស់វា
object.canGoBack
វាជា read only property ដែលជា true បើសិនជា web view អាចត្រឡប់ទៅក្រោយ a webpage & false if not

object.canGoForward
វាជា read only property ដែលបើសិនជា true បើសិន web view អាចទៅមុខបាន a webpage & false if not      

object.hasBackground
វាជា get/set property ដែល corresponds ថា whether or not the background របស់ web view គឺ visible or transparent។ តំលៃដើមគឺ true



Methods
 (Inherits methods from NativeDisplayObject)

object:back()
វាយកនៅ webView back ត្រឡប់ទៅកាន់ webView’s history
Syntax: object:back()

object:forward()
ប្រើសំរាប់យកវាទៅកាន់ forward one step នៅក្នុង webView’s history
Syntax: object:forward()
                       
object:reload()
ប្រើសំរាប់ reloads នៅ currently loaded page នៅក្នុង webView
Syntax: object:reload()      

object:request()
វាប្រើសំរាប់ load specified url (string) ទៅក្នុង webView។ សំរាប់ local content,  ត្រូវតែដាក់នៅ specify a base directory ដូចជា search path
Syntax: object:request (url)
Object:request(url, baseDir)
url(តំរូវការ) វាជា String, the url to load, សំរាប់ local files វាគឺជា path relative to baseDir
baseDir(ជំរើស) វាជា constant, ដែល a base directory constant

ចំណាំះ
សំរាប់ android, បើសិនជាវាបង្ហាញនៅ web view ពី internet, ពេលនោះវាបន្ថែមនៅ internet permission “build.settings” file។ ដែល permission មិនសំខាន់ទេបើសិនជាវាបង្ហាញតែលើ local HTML files ដែលមិនបាន access ចូលទៅកាន់ internet

settings ={    android =    {        usesPermissions =        {
            "android.permission.INTERNET",        },    },​​}

សូមមើលកូដះ
 local webView = native.newWebView( 0, 0, 320, 480 )
webView:request( "http://www.coronalabs.com/" )
                                     
object:stop()
ប្រើសំរាប់ stop loading current page នៅក្នុង webView (if loading)
Syntax: object:stop()               


នេះជា Type Video របស់ Corona SDK

នេះជា Type Video របស់ Corona SDK
វាជា Video object ដែលជា native display object។ អាច move it, rotate it or even add a physics body
ចំណាំះ នៅលើ IOS វាមានដែនកំនត់នៃលេខ simultaneous video objects ដែលអាចលែងបាន

Properties
(Inherits properties from NativeDisplayObject)
object.currentTime
វាជា Current time position នៃ video នៅក្នុង seconds (read-only) ប្រើវាជា conjunction ជាមួយនឹង native.newVideo()

object.isMuted    
ប្រើសំរាប់គ្រប់គ្រង់ Video’s audio channel is muted។ ប្រើវាជាមួយនឹង conjunction ជាមួយនឹង native.newVideo()

object.totalTime
វាជាប្រវែងនៃ currently loaded video ជាវិនាទី។​ វាត្រូវបានហៅបន្ទាប់ពី Video គឺត្រូវបានរៀបចំលេង ឬក៏ inaccurate value ដែលអាចត្រលប់
Methods
(Inherits methods from NativeDisplayObject)

object:load()
ប្រើសំរាប់ Loads a specified video។ ប្រើជាមួយនឹង conjunction with native.viewVideo()
Syntax: object:load (path)
Object:load (path, baseSource)
Path(តំរូវការ) វាជា String, ដែលជា local filename or remote URL សំរាប់ Video
baseSource (ជំរើស) វាជា constant, ដែលគ្រប់គ្រង់លើ Path is interpreted។ វាអាចជា one of the system defined directory constants or media.RemoteSource(use this to access video on a remote server)

object:pause()
ប្រើសំរាប់ Pauses នៅ currently loaded video, ប្រើជាមួយនឹង conjunction native.newVideo()
Syntax: object:pause()


object:play()               
ប្រើសំរាប់លេងជាមួយនឹង currently loaded video, ប្រើជាមួយនឹង conjunction ជាមួយនឹង native.newVideo()
Syntax: object:play()

object:seek()
ប្រើសំរាប់ស្វែងរក & Jumps នៅពេលណាមួយនៅក្នុង currently loaded video, ប្រើជាមួយនឹង conjunction native.newVideo()
Syntax: object:seet (timeInSeconds)
timeInSeconds (តំរូវការ) វាជាចំនួនលេខដែល jumps នៅ specified time នៅក្នុង currently loaded videoensure that this is not greater than the object.totalTime property


នេះជា Type TextObject របស់ Corona SDK

នេះជា Type TextObject របស់ Corona SDK
វាជា Text Object ដែលបង្កើតឡើងដោយការប្រើនៅ display.newText() function

(Inherits properties from DisplayObject)
object.size
ប្រើសំរាប់ទាញឬបញ្ចូលនៅទំហំរបស់ text នៅក្នុង text object
សូមមើលកូដះ
local myText = display.newText( "", 0, 0, native.systemFont, 12 )
myText:setFillColor( 1, 1, 1 )
myText.text = "Hello World!"
myText.size = 16

object.text
ប្រើសំរាប់ទាញឬបញ្ចូលនៅ Text string របស់ ​Text Object
ចំណាំះ នៅពេលផ្លាស់ប្តូរនៅ text string របស់ text object, អាចបញ្ចូលនៅ its anchor point & ទីតាំងរបស់ x/y ម្តងទៀត។ ការធ្វើដូចនេះនឹងប្រាកដនៅ object remains aligned ទៅកាន់ ទីតាំងដើម។
សូមមើលកូដះ
local myText = display.newText( "Hello", 0, 0, native.systemFont, 12 )
myText.x = 50 ; myText.y = 50
myText:setFillColor( 1, 1, 1 )
myText.anchorX = 0
-- Change the text
myText.text = "Hello World!"

Methods
(Inherits methods from DisplayObject)

object:setFillColor()
ប្រើសំរាប់បញ្ចូលទៅកាន់ fill color of vector ហើយនឹង text objects។ វា applies a tint ទៅកាន់ image objects
Syntax:
object:setFillColor( gray )
object:setFillColor( gray, alpha )
object:setFillColor( red, green, blue )
object:setFillColor( red, green, blue, alpha )
object:setFillColor( gradient )

gray, red, green, blue, alpha (optional)
វាជាចំនួនលេខដែលនៅចន្លោះ 0 and 1 that represent the corresponding តំលៃសំរាប់ channel alpha represents the opacity of the object.
gradient (optional)
វាជាតារាងដែលឃើញ gradient fill example ដូចខាងក្រោម

ចំណាំះ
In builds based on V1 Graphics, continue using setTextColor() to set the fill color for text objects created via display.newText().

សូមមើលកូដះ

Vector Object Fill
 local vertices = { 0,-110, 27,-35, 105,-35, 43,16, 65,90, 0,45, -65,90, -43,15, -105,-35, -27,-35 }
local star = display.newPolygon( 300, 300, vertices )
star:setFillColor( 1, 0.2, 0.2 )
Text Object Fill
 local myText = display.newText( "hello", 0, 0, native.systemFontBold, 12 )

myText:setFillColor( 1, 0.2, 0.2 )
Gradient Fill
 local rect = display.newRect( 0, 0, 100, 200 )

local gradient = {
    type="gradient",
    color1={ 1, 1, 1 }, color2={ 0.8, 0.8, 0.8 }, direction="down"
}
rect:setFillColor( gradient )

Image Tint
local image = display.newImage( "image.png" )
image:setFillColor( 0.72, 0.9, 0.16, 0.78 )  -- Tints image green

object:setEmbossColor()
ប្រើសំរាប់បញ្ចូលនៅ Color parameters សំរាប់ embossed text object ដែលបានបង្កើតឡើងតាមរយះ display.newEmbossedText()
Syntax: object:setEmbossColor (colorTable)
colorTable(តំរូវការ)វាជាតារាងដែលរួមបញ្ចូលនៅឈ្មោះ sub-tables ចំនួនពីរសំរាប់ highlight & shadow សំរាប់ embossed text object។ សំរាប់ table នីមួយៗអាចផ្ទុកនៅ RGB+A color values for respective property
សូមមើលកូដះ
local myText = display.newEmbossedText( "hello", 200, 100, native.systemFont, 40 )
myText:setFillColor( 0.5 )
myText:setText( "Hello World!" )

local color =
{
    highlight = { r=1, g=1, b=1 },
    shadow = { r=0.3, g=0.3, b=0.3 }
}
myText:setEmbossColor( color )                  


នេះជា Type TextFieldtex របស់ Corona SDK

នេះជា Type TextFieldtex របស់ Corona SDK
វាជា native text field ដែលជា single line input field សំរាប់បង្ហាញនៅ text based content, សូមមើលនៅ native.newTextField()សំរាប់ពត័មានលំអិត
ចំណាំះ      
សំរាប់ Native text fields មានតែលើ device builds & Mac Simulator មិនមាននៅលើ Windows Simulator
នេះជា Properties របស់វា
object.align
វាប្រើសំរាប់ Alignment របស់ text ដែលបង្ហាញនៅ input text field វាអាចបញ្ចូលនៅ String ដូចខាងក្រោមះ left, center, right
សូមមើលកូដះ
local nameField = native.newTextField( 50, 150, 220, 36, handlerFunction )
nameField.align = "center"
                
object.font
វាជា Font នៃ text input field, ដែលត្រូវបញ្ចូលទៅកាន់ font object ជា returned តាមរយះ native.newFont()
សូមមើលកូដះ
local myField = native.newTextField( 10, 30, 180, 30, fieldHandler )
local myField.font = native.newFont( native.systemFontBold, 18 )    
         
                                     
object.hasBackground
វាប្រើសំរាប់គ្រប់គ្រង់ថាតើ text box មាន opaque background or not។ តំលៃដើម true (opaque)
សូមមើលកូដះ
-- Draw red background
local r = display.newRect( 0, 0, 320, 480 )
r:setFillColor( 1, 0, 0 )

-- Textfield, with transparent background
local t = native.newTextField( 30, 140, 260, 100 )
t.font = native.newFont( "Helvetica-Bold", 16 )
t:setTextColor( 0.8, 0.8, 0.8 )
t.hasBackground = false
t.text = "Hello, world!"



object.inputType
វាជា keyboard type របស់ native text input field។ ដែលតំលៃរបស់វាមាន
Default ជា default keyboard, ដែល supporting general text, numbers & punctuation
Number ជា numeric keypad
Decimal​ ជា keypad សំរាប់បញ្ចូលនៅចំនួន decimal value
Phone ជា keypad សំរាប់បញ្ចូលនៅចំនួនលេខទូរស័ព្ទ
url ជា keypad សំរាប់បញ្ចូលនៅ website URLs
email ជា keypad សំរាប់បញ្ចូលនៅ Email addresses
ចំណាំះ ដើម្បីបង្កើតនៅ Password entry field ត្រូវបញ្ចូលនៅ object.isSecure Boolean property
សូមមើលកូដះ
local numericField = native.newTextField( 50, 150, 220, 36, handlerFunction )
numericField.inputType = "number"
                
object.isSecure
វាជាការគ្រប់គ្រងថាតើ text នៅក្នុង field គឺ Obscured, e.g passwords, default is false
សូមមើលកូដះ
local passwordField = native.newTextField( 100, 50, 40, 30, inputListener )
passwordField.inputType = "number"
passwordField.isSecure = true

object.placeholder
សំរាប់ Native text fields អាចបង្ហាញនៅ optional placeholder text (nil, by default) វាអាចផ្តល់នៅ hint ដែលអ្នកប្រើអាចបញ្ចូលនៅក្នុង Field។ បើសិនជាបញ្ចូលវានៅ Placeholder string ដែលបង្ហាញនៅការប្រើប្រាស់ the same style information (except the text color) សំរាប់ placeholder មិនបង្ហាញនៅ actual text ដែលបានបញ្ចូលទៅក្នុង field ទេហើយមិន participate in determining the size of the text field
សូមមើលកូដះ
local numericField = native.newTextField( 150, 150, 220, 36 )
numericField.inputType = "number"
-- Optional placeholder (hint) for the text field
numericField.placeholder = "(phone number)"
numericField:addEventListener( "userInput", handlerFunction )

object.size
វាជា font size របស់ text នៅក្នុង native text input field
សូមមើលកូដះ
local field1 = native.newTextField( 50, 100, 100, 35 )
field1.align = "center"
field1.size = 32
field1:setTextColor( 1, 0.5, 0 )
field1.text = "Hello World!"

object.text
វាជា contents របស់ native text input field
សូមមើលកូដះ
local field1 = native.newTextField( 50, 100, 100, 35 )
field1.align = "center"
field1.size = 32
field1:setTextColor( 1, 0.5, 0 )
field1.text = "Hello World!"

Methods
(Inherits methods from NativeDisplayObject)
object:setTextColor()       
ប្រើសំរាប់បញ្ចូលនៅ Color របស់ text នៅក្នុង native text input field
Syntax: object:setTextColor (r,g,b)
Object:setTextColor(r,g,b,a)
R,g,b(តំរូវការ) វាជាចំនួនលេខដែលនៅតំលៃពី ០នឹង១ សំរាប់ red,green & blue channels
A(ជំរើស) វាជាចំនួនលេខដែលនៅចន្លោះ ០នឹង ១ សំរាប់ alpha channel default is 1
សូមមើលកូដះ
local field1 = native.newTextField( 50, 100, 100, 35 )
field1.align = "center"
field1.size = 32
field1:setTextColor( 1, 0.5, 0 )
field1.text = "Hello World!"

object:setReturnKey()
ប្រើសំរាប់បញ្ចូលនៅ return key របស់ keyboard
Syntax: object:setReturnKey (key)
Key(តំរូវការ) វាជា String ដែលជា type name របស់ return button



Valid key Values
 •done(Android and iOS)
 •go(Android and iOS)
 •next(Android and iOS)
 •search(Android and iOS)
 •send(Android and iOS)
 •none(Android)
 •default(iOS)
 •join(iOS)
 •route(iOS)
 •emergencycall(iOS)

ចំណាំះ
Setting the return key to done causes no button to show up on the original Kindle Fire.

សូមមើលកូដះ
 local textField = native.newTextField( 30, 140, 260, 150 )
textField:setReturnKey("done")           


នេះជា Type TextBox របស់ Corona SDK

នេះជា Type TextBox របស់ Corona SDK
វាជា native text box ដែលអាច scrollable។ វាជា multi line input field សំរាប់បង្ហាញនៅ text based content។ សូមមើល native.newTextBox() សំរាប់ពត័មានលំអិត
ចំណាំះ វាមានតែលើ Device builds & Mac Simulator, មិនមាននៅលើ Windows Simulator
នេះជា Properties របស់វា
(Inherits properties from NativeDisplayObject)
 object.align
 ប្រើសំរាប់ Alignment នៃ text ដែលបង្ហាញនៅក្នុង text box។ វាអាចបញ្ចូលនៅ String ដូចខាងក្រោមះ
Left, center, right
សូមមើលកូដះ
local inputBox = native.newTextBox( 160, 240, 280, 140 )
inputBox.align = "center"

object.font
វាជា font របស់ ​text box។ វាអាចបញ្ចូលនៅ font object ដែលត្រឡប់ជា native.newFont()
សូមមើលកូដះ
Local myBox = native.newTextBox (160,240,280,140, fieldHandler)
local myBox.font = naitve.newFont (native.systemFontBold, 18)

object.hasBackground
ប្រើសំរាប់គ្រប់គ្រងថាតើ text box មាន opaque background ឬអត់។ តំលៃដើមគឺ true (opaque)
សូមមើលកូដះ
-- Draw red background
local r = display.newRect( 0, 0, 320, 480 )
r:setFillColor( 1, 0, 0 )

-- Text with transparent background
local t = native.newTextBox( 160, 240, 280, 140 )
t.font = native.newFont( "Helvetica-Bold", 16 )
t:setTextColor( 0.8, 0.8, 0.8 )
t.hasBackground = false
t.text = "Hello, world!"
object.isEditable
ប្រើសំរាប់គ្រប់គ្រងថាតើ text box គឺអាច editable។ តំលៃដើមគឺ false
សូមមើលកូដះ
local fieldHandler = function( event )
    print( event.phase )
    if "began" == event.phase then
        -- do something
    elseif "ended" == event.phase then
        -- do something
    elseif "submitted" == event.phase then
        -- do something
    end
end
local inputBox = native.newTextBox( 160, 240, 280, 140, fieldHandler )
inputBox.isEditable = true
                                                         
object.placeholder
នេះជា native text boxes អាចបង្ហាញនៅ optional placeholder text (nil by default) ។ វាអាចផ្តល់នៅ hint នៅអី្វដែលអ្នកប្រើអាចបញ្ចូលទៅក្នុង boxបើសិនជាបញ្ចូលនៅ placeholder string អាចបង្ហាញនៅ same style information (except the text color) ។ សំរាប់ placeholder មិនបង្ហាញនៅ actual text ដែលបានបញ្ចូលទៅកាន់ box ហើយមិនគិតអំពីទំហំរបស់ text box
សូមមើលកូដះ
local textBox = native.newTextBox( 160, 240, 280, 140 )
-- Optional placeholder (hint) for the text box
textBox.placeholder = "(description)"

object.size
វាជា font size របស់ text នៅក្នុង native text input box
សូមមើលកូដះ
local textBox = native.newTextBox( 160, 240, 280, 140 )
textBox.font = native.newFont( "Helvetica-Bold", 12 )
textBox:setTextColor( 0.8, 0.8, 0.8 )
textBox.hasBackground = false
textBox.text = "Hello World!"
-- change size property
textBox.size = 18


object.text
វាជា contents របស់ native text input box
សូមមើលកូដះ
local textBox = native.newTextBox( 160, 240, 280, 140 )
textBox.font = native.newFont( "Helvetica-Bold", 18 )
textBox:setTextColor( 0.8, 0.8, 0.8 )
textBox.alpha = 1.0
textBox.hasBackground = false
textBox.text = "Hello World!"


Methods
(Inherits methods from NativeDisplayObject)

object:setTextColor()
ប្រើសំរាប់ បញ្ចូលនៅ color of the text នៅក្នុង native text input box
Syntax: object:setTextColor (r,g,b)
Object:setTextColor (r,g,b,a)
R,g,b (តំរូវការ) វាជាចំនួនលេខដែលនៅចន្លោះ០នឹង​១ សំរាប់​ red, green​​ & blue channels
A(ជំរើស) វាជាចំនួនលេខដែលនៅចន្លោះ ០នឹង១ សំរាប់ alpha channel។​the default is 1
សូមមើលកូដះ
local textBox = native.newTextBox( 160, 240, 280, 140 )
textBox.font = native.newFont( "Helvetica-Bold", 18 )
textBox:setTextColor( 0.8, 0.8, 0.8 )
textBox.alpha = 1.0
textBox.hasBackground = false
textBox.text = "Hello World!"

object:setReturnKey()
ប្រើសំរាប់បញ្ចូលនៅ return key នៃ keyboard
Syntax: object:setReturnKey(key)
Key(តំរូវការ) វាជា String ដែលជា type name នៃ return button

Valid key Values
 •done(Android and iOS)
 •go(Android and iOS)
 •next(Android and iOS)
 •search(Android and iOS)
 •send(Android and iOS)
 •none(Android)
 •default(iOS)
 •join(iOS)
 •route(iOS)
 •emergencycall(iOS)

ចំណាំះ
Setting the return key to done causes no button to show up on the original Kindle Fire.

សូមមើលកូដះ
 local textBox = native.newTextBox( 160, 240, 280, 140 )
textBox.isEditable = true
textBox:setReturnKey("done")

នេះជា Type TabBarWidgets របស់ Corona SDK

នេះជា Type TabBarWidgets របស់ Corona SDK
សំរាប់ TabBar objects ត្រូវបានបង្កើតឡើងដោយប្រើ widget.newTabBar()
នេះជា Methods របស់វា
Object:setSelected() ការប្រើនៅវិធីនេះសំរាប់ TabBar button ទៅកាន់ selected state។ ជាជំរើសវាអាច invoke នៅលើ onPress listener សំរាប់ ​button នៅពេលដូចគ្នា
Syntax: object:setSelected (buttonIndex)
Object:setSelected (buttonIndex, simulatePress)
buttonIndex (តំរូវការ) វាជាចំនួនលេខដែល button index នៅលើ tab bar ចាប់ផ្តើមជាមួយនឹង១ បង្ហាញថា button ចេញពីឆ្វេង
simulatePress (ជំរើស) វាជា Boolean បើសិនជាបញ្ចូលជា true the tab button តាមរយះ buttonIndex វានឹងមាន onPress listener function calledthe default is false មានន័យថា tab button នឹងបង្ហាញការ selected ប៉ុន្តែ listener function មិនត្រូវបានយកមកប្រើ
សូមមើលកូដះ
-- Select the 3rd tab.
tabBar:setSelected( 3 ) 

-- Select the 2nd tab button and invoke its listener function
tabBar:setSelected( 2, true )