lua真的有很多神奇的用法,下面是一个基于表的形式实现的对于GUI的定义。支持事件响应等。 可以在线(http://www.lua.org/cgi-bin/demo)测试运行效果。 -- Canvas Canvas = { ["frame_msg.OFrame"] = { skin="Engine\\Standard.OSkin1StateFrame", image="Engine\\StandardDialog.OTexture2D", left=148, top=90, right=700, bottom=10, titlebar=false, closebtn=false, ontick = function( self ) print( self.image ) end, ["button_ok.OButton"] = { skin="Engine\\Standard.OSkin3StateButton", image="Engine\\StandardBtn.OTexture2D", font={ "Engine\\Harabara.OTrueTypeFontface" }, left=148, top=90, right=276, bottom=10, text="确定", onclick = function( self ) print("button ok is clicked.") print(self.text) self.text = "取消" print(self.text) end } } } Canvas["frame_msg.OFrame"]:ontick() Canvas["frame_msg.OFrame"]["button_ok.OButton"]:on click() 具体比较详细的教程:
相关资源:七夕情人节表白HTML源码(两款)