-- [Nanyang caolu Software Technology Co., Ltd. hi.baidu.com/xingyan12642520.waxclass {"appdelegate", protocols = {"uiapplicationdelegate"} -- well done! You are almost ready to run a Lua app on your iPhone! ---- Just run the app (simulator) in the simulator or on a device! -- You will see a dull, bland "Hello World" app (it is your job to spice it up .) ---- if your prefer using textmate to edit the Lua code just type -- 'rake TM 'from the command line to setup a wax textmate project. ---- what's next? -- 1. Check out some of the example apps to learn how to do -- more complicated apps. -- 2. Then you start writing your app! -- 3. let us know if you need any help at http://groups.google.com/group/iphonewaxlocal tbdef = {['stair _ normal'] = {0, 0, 60, 18 }, ['stair _ moveh'] = {0, 18, 60, 36}, ['stair _ movev'] = {0, 36, 60, 54 }, ['stair _ on1'] = {0, 54, 60, 72}, ['stair _ false1'] = {0, 72, 60, 90} Local btndef = {['play'] = {50,150}; ['mutabilplayer'] = {100,200}; ['score '] = {250,300 }; ['operation'] = {200,350}; ['stair'] = {40, 400}; ['domain'] = {55,380};} function applicationdidfinishlaunching (self, application) Local frame = uiscreen: mainscreen (): bounds () window = uiwindow: initwithframe (FRAME) window: setbackgroundcolor (uicolor: colorwithred_green_blue_alpha (0.196, 0.725, 0.702, 1) self. background = uiimageview: initwithframe (FRAME) self. background: setimage (uiimage: imagenamed ("bck.png") window: addsubview (self. background) Local label = uilabel: initwithframe (cgrect (0,100,320, 40) label: setfont (uifont: boldsystemfontofsize (30) label: setcolor (uicolor: whitecolor () label: setbackgroundcolor (uicolor: colorwithred_green_blue_alpha (0.173, 0.651, 0.627, 1) label: settext ("Hello Lua! ") Label: settextalignment (uitextalignmentcenter) window: addsubview (Label) menu () self. window: makekeyandvisible () endfunction menu () Local imgplay = uiimage: imagenamed ("play.png") Local p = btndef ['play'] local size = imgplay: size () local play = uibutton: initwithframe (cgrect (P [1], p [2], size. width, size. height) Play: setbackgroundimage_forstate (imgplay, 0) window: addsubview (play) Local imgmultiplayer = uiimage: imagenamed ("multiplayer-on.png") P = btndef ['mutabilplay'] size = imgmultiplayer: size () multiplayer = uibutton: initwithframe (cgrect (P [1], p [2], size. width, size. height) multiplayer: setbackgroundimage_forstate (imgmultiplayer, 0) window: addsubview (Multiplayer) imstair = uiimage: imagenamed ("statr1-0.png") size = imstair: size () P = btndef ['stair'] local stair = uiimageview: initwithframe (cgrect (P [1], p [2], size. width, size. height); STAIR: setimage (imstair) window: addsubview (STAIR) Local imgdoodle = uiimage: imagenamed ("lik-right.png") size = imgdoodle: size () doview = uiimageview: initwithframe (cgrect (P [1] + 10, P [2]-size. height + 4, size. width, size. height) doodle: setimage (imgdoage) window: addsubview (doview); -- enable the thread ismenu = ture G = 10 V0 =-100; timer = nstimer: Average (0.01, self, "handletimer:", nil, true) end COUNT = 1 function handletimer () jumpthread () end -- parabolic motion function jumpthread () Local rect = DOCT: frame () local deta_t = 0.1 VT = V0 + G * deta_t local S = (V0 * deta_t + G * deta_t)/2; rect. y = rect. Y + S; V0 = Vt if V0> 100 or V0 = 100 then V0 =-100 rect. y = btndef ['stair'] [2]-rect. height + 4 end doplay: setframe (rect) doodle: setneedsdisplay () endfunction splitepng (IMG, rect) print (type ('function call') Local cgimg = wax. cgcontext. reverse (IMG: cgimage (), rect) image = uiimage: imagewithcgimage (cgimg) return imageendfunction applicationdidbecomeactive (self, application) endfunction appdelegate: applicationdidenterbackground (Application) End
Lua code above
Project: doodlejump.zip