基本信息
源码名称:android 发射弹球小游戏 附完整源码下载
源码大小:0.15M
文件格式:.zip
开发语言:Java
更新时间:2013-05-24
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
android 弹球游戏制作
package wyf.ytl; //声明包语句
public class BallGoThread extends Thread {
GameView father;
boolean flag = true;
public BallGoThread(GameView father) {
this.father = father;
}
public void run() {
while (flag) {
switch (father.direction) {
case 0:
// 右上
// 当在向右上角移动的时候x坐标加,y坐标减
father.ballx = father.ballx father.ballSpan;
father.bally = father.bally - father.ballSpan;
//当碰到右边的墙壁的时候,向左下飘
if (father.ballx >= father.screenWidth - father.ballSize) {
father.direction = 3;
} else if (father.bally <= 0) {
// 碰到上壁,产生反射向右下飘
father.direction = 1;
}
break;
case 3:
// 向左上角飘,x坐标逐渐减,y坐标逐渐减
father.ballx = father.ballx - father.ballSpan;
father.bally = father.bally - father.ballSpan;
if (father.ballx <= 0) {// 碰到左壁
father.direction = 0;
} else if (father.bally <= 0) {// 碰到上壁
father.direction = 2;
}
break;
case 1:
// 向右下角飘
father.ballx = father.ballx father.ballSpan;
father.bally = father.bally father.ballSpan;
if (father.bally >= father.screenHeight - father.bannerHeight
- father.bottomSpance - father.ballSize) {// 碰到下壁
checkCollision(1);
} else if (father.ballx >= father.screenWidth - father.ballSize) {// 碰到右壁
father.direction = 2;
}
break;
case 2:
// 向左下角飘
father.ballx = father.ballx - father.ballSpan;
father.bally = father.bally father.ballSpan;
if (father.bally >= father.screenHeight - father.bannerHeight
- father.bottomSpance - father.ballSize) {// 碰到下壁
checkCollision(2);
} else if (father.ballx <= 0) {// 碰到左壁
father.direction = 1;
}
break;
}
try {
Thread.sleep(80);
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void checkCollision(int direction) {
if (father.ballx >= father.bannerX - father.ballSize
&& father.ballx <= father.bannerX father.bannerWidth) {// 碰到板
switch (direction) {
case 1:
father.direction = 0;
break;
case 2:
father.direction = 3;
break;
}
} else {// 没有碰到板
// 游戏失败
father.tt.flag = false;
father.bgt.flag = false;
father.status = 2;
}
}
}