123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- require "import"--我最初把这个发到robin那个代码手册上来了结果一个人给我搬运到这个论坛了
- import "android.app.*"
- import "android.os.*"
- import "android.widget.*"
- import "android.view.*"
- import "android.graphics.Path"
- import "android.graphics.Paint"
- import "android.graphics.Color"
- import "android.graphics.RectF"
- import "java.io.*"
- function 加载()
- function 提示(text)
- Toast.makeText(activity,text,Toast.LENGTH_SHORT).show()
- end
- function 随机数(min,max)
- return math.random(min,max)
- end
- function 获取屏幕宽()
- return activity.getWidth()
- end
- function 获取屏幕高()
- return activity.getHeight()
- end
- layout=
- {
- LinearLayout;
- layout_height="fill";
- orientation="horizontal";
- layout_width="fill";
- {
- RelativeLayout;
- layout_width="match_parent";
- layout_height="match_parent";
- {
- LinearLayout;
- layout_width="match_parent";
- id="背景布局";
- layout_height="match_parent";
- {
- LinearLayout;
- layout_height="match_parent";
- layout_gravity="center";
- id="绘制目标";
- layout_width="match_parent";
- };
- };
- {
- LinearLayout;
- layout_width="match_parent";
- layout_height="match_parent";
- {
- LinearLayout;
- layout_height="180dp";
- layout_gravity="bottom";
- layout_width="match_parent";
- orientation="vertical";
- backgroundColor="";
- {
- LinearLayout;
- gravity="center";
- layout_gravity="right";
- layout_width="180dp";
- layout_height="180dp";
- {
- Button;
- layout_height="70dp";
- text="跳";
- id="跳";
- layout_width="70dp";
- };
- };
- };
- };
- {
- TextView;
- hint="游戏数据";
- id="数据反馈";
- textColor="0xFFFF1B44";
- gravity="center";
- layout_width="match_parent";
- };
- };
- };
- activity.setContentView(loadlayout(layout))
- activity.setRequestedOrientation(0);
- 数值=获取屏幕宽()
- 数值二=获取屏幕高()
- 数据=数值/2
- 数据二=数值二/2
- 高度=100
- 刷新=Ticker()
- 刷新.Period=100
- 刷新.onTick=function()
- 绘制目标.setBackground(
- LuaDrawable(
- function(画布,画笔)
- 画笔.setColor(0xFF009FFF)
- 画布.drawCircle(获取屏幕高(),高度,50,画笔)
- end))
- end
- 间隔=10
- 加值=1
- 高度刷新=Ticker()
- 高度刷新.Period=间隔
- 高度刷新.onTick=function()
- 高度=高度+加值
- end
- 高度刷新.start()
- 刷新.start()
- 状态=Ticker()
- 状态.Period=100
- 状态.onTick=function()
- 判断上=数据-高度
- 判断下=高度
- if 判断上>=数据 or 判断下>=数值 then
- print("游戏结束")
- 跳.onClick=function()
- 分数=0
- 等级=1
- 间隔=10
- 加值=1
- 跳跃高度=120
- 加载()
- end
- 状态.stop()
- 高度刷新.stop()
- 刷新.stop()
- 反馈.stop()
- 刷新分数.stop()
- 等级刷新.stop()
- 地狱刷新.stop()
- else
- end
- end
- 分数=0
- 分数间隔=1000
- 刷新分数=Ticker()
- 刷新分数.Period=分数间隔
- 刷新分数.onTick=function()
- 分数=分数+1
- end
- 等级=1
- 等级刷新=Ticker()
- 等级刷新.Period=4000
- 等级刷新.onTick=function()
- if 间隔<=3 or 跳跃高度<= 100 then
- 等级="地狱"
- 等级刷新.stop()
- 跳跃高度=跳跃高度+20
- 分数间隔=25
- 地狱开始()
- 地狱刷新.start()
- else
- 等级=等级+1
- 间隔=间隔-1
- 加值=加值+1
- 跳跃高度=跳跃高度-2
- end
- end
- 反馈=Ticker()
- 反馈.Period=50
- 反馈.onTick=function()
- 数据反馈.setText("分数:"..分数.."\n高度:"..高度.."\n等级:"..等级.."\n屏幕宽:"..获取屏幕宽().."\n屏幕高:"..获取屏幕高().."")
- end
- 状态.start()
- 反馈.start()
- 刷新分数.start()
- 等级刷新.start()
- 跳跃高度=120
- 跳.onClick=function()
- 高度=高度-跳跃高度
- end
- function 地狱开始()
- 地狱刷新=Ticker()
- 地狱刷新.Period=500
- 地狱刷新.onTick=function()
- 数据二=随机数(0,""..获取屏幕高().."")
- end
- end
- 地狱开始()
- end
- 加载()
|