iphone上用lua做了个doodlejump的菜单界面
2012-04-25 12:11
239 查看
--[[南阳草庐软件科技有限公司 hi.baidu.com/xingyan126 ]] waxClass{"AppDelegate", protocols = {"UIApplicationDelegate"}} -- Well done! You are almost ready to run a lua app on your iPhone! -- -- Just run the app (⌘↵) 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/iphonewax local 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}; ['doodle'] ={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() end function 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['mutabilplayer'] size = imgMultiplayer:size() multiPlayer = UIButton:initWithFrame(CGRect(p[1], p[2], size.width, size.height)) multiPlayer:setBackgroundImage_forState(imgMultiplayer, 0) window:addSubview(multiPlayer) imgStair = UIImage:imageNamed("statr1-0.png") size = imgStair:size() p = btnDef['stair'] local stair = UIImageView:initWithFrame(CGRect(p[1], p[2], size.width, size.height)); stair:setImage(imgStair) window:addSubview(stair) local imgdoodle = UIImage:imageNamed("lik-right.png") size = imgdoodle:size() doodle = UIImageView:initWithFrame(CGRect(p[1]+10, p[2]-size.height+4, size.width, size.height)) doodle:setImage(imgdoodle) window:addSubview(doodle); --开启线程 ismenu = ture g = 10 v0 = -100; timer = NSTimer:scheduledTimerWithTimeInterval_target_selector_userInfo_repeats(0.01, self, "handleTimer:", nil, true) end count = 1 function handleTimer() jumpthread() end --抛物运动 function jumpthread() local rect = doodle:frame() local deta_t = 0.1 vt = v0 + g*deta_t local s = (v0*deta_t + g*deta_t*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 doodle:setFrame(rect) doodle:setNeedsDisplay() end function splitePNG(img, rect) print(type('函数调用')) local cgimg = wax.CGContext.CGImageCreateWithImageInRect(img:CGImage(), rect) image = UIImage:imageWithCGImage(cgimg) return image end function applicationDidBecomeActive(self, application) end function AppDelegate:applicationDidEnterBackground(application) endlua代码如上
项目下载地址:doodlejump.zip
相关文章推荐
- Android 设置界面修改为Iphone的tab菜单风格
- 简易菜单界面
- 关于iphone界面设计的一些尺寸问题
- iPhone界面跳转及页面传值
- 用代码修改iPhone界面
- Flash图表FusionCharts如何自定义图表导出菜单或界面
- 30套精美的 iDevices(iPhone, iPad, iOS)PSD 界面素材资源
- iLuaBox:在iPhone/iPad上随时随地用Lua编程
- javascript仿qq界面的折叠菜单实现代码
- 《开发之旅》学习笔记:游戏界面手动打造菜单基础元素
- 在Mac上显示iPhone界面
- iPad、iPhone 界面设计标准
- 如何利用Android TabHost+ActivityGroup+Broadcast实现类似于iPhone的底部菜单
- iOS:界面适配(三)--iPhone不同机型适配 6/6plus 前
- C#之使用NotifyIcon实现任务栏托盘菜单,图标闪烁效果及气泡提示 很多程序是只需要后台运行的,甚至不需要自己的应用界面。NotifyIcon提供了程序在任务栏的显示功能 程序下载链接如下
- 界面优美开源iPhone App编译步骤
- Android Design Support Library(二)用NavigationView实现抽屉菜单界面
- Swing界面的布局联系(学生成绩管理系统登录界面演示和菜单栏、菜单项、菜单的布局方式演示)
- LCD 1602字符菜单界面实现 [李园7舍_404]
- Android界面设计(APP设计趋势 左侧隐藏菜单右边显示content)