基於表的Lua原生支援物件導向編程在GUI中的使用樣本

來源:互聯網
上載者:User

標籤:

http://blog.csdn.net/cnjet/article/details/5974212

 

lua真的有很多神奇的用法,下面是一個基於表的形式實現的對於GUI的定義。支援事件響應等。

可以線上(http://www.lua.org/cgi-bin/demo)測試回合效果。

 

 

 

[cpp] view plaincopy 
  1. -- Canvas  
  2. Canvas = {  
  3.       ["frame_msg.OFrame"] = {  
  4.          skin="Engine//Standard.OSkin1StateFrame",  
  5.          image="Engine//StandardDialog.OTexture2D",  
  6.          left=148,  
  7.          top=90,  
  8.          right=700,  
  9.          bottom=10,  
  10.          titlebar=false,  
  11.          closebtn=false,  
  12.          ontick = function( self )  
  13.                print( self.image )  
  14.          end,  
  15.         ["button_ok.OButton"] = {  
  16.             skin="Engine//Standard.OSkin3StateButton",  
  17.             image="Engine//StandardBtn.OTexture2D",  
  18.             font={ "Engine//Harabara.OTrueTypeFontface" },  
  19.             left=148,  
  20.             top=90,  
  21.             right=276,  
  22.             bottom=10,  
  23.             text="確定",  
  24.             onclick = function( self )  
  25.                  print("button ok is clicked.")  
  26.                  print(self.text)  
  27.                  self.text = "取消"  
  28.                  print(self.text)  
  29.             end  
  30.          }  
  31.     }  
  32. }  
  33. Canvas["frame_msg.OFrame"]:ontick()  
  34. Canvas["frame_msg.OFrame"]["button_ok.OButton"]:onclick()  

 

 

 

具體比較詳細的教程:

http://lua-users.org/wiki/ObjectOrientationTutorial

基於表的Lua原生支援物件導向編程在GUI中的使用樣本

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.