package jack.wallpaper;
//Download by http://www.codefans.net
import java.util.Random;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
public class BubbleControl
{
private int mWidth;
private int mHeight;
private int mBubblesNum;
private Bubbles[] mBubbles;
private Random mRandom;
public boolean showSnow=true;
public BubbleControl(int Width, int Height)
{
mWidth = Width;
mHeight = Height;
mRandom = new Random();
}
public void initBubbles(int BubblesNum)
{
mBubblesNum = BubblesNum;
mBubbles = new Bubbles[mBubblesNum];
if (showSnow)
{
for (int i = 0; i < mBubblesNum; i++)
{
mBubbles[i] = new Bubbles();
mBubbles[i].setX(mRandom.nextInt(mWidth));
mBubbles[i].setRadius(mRandom.nextInt(3));
mBubbles[i].setY(-mBubbles[i].getRadius());
mBubbles[i].setColor(Color.WHITE);
mBubbles[i].setX_Speed(mRandom.nextInt(4) - 2);
mBubbles[i].setY_Speed(mRandom.nextInt(5) +1);
mBubbles[i].isLive = mRandom.nextBoolean();
}
}
else
{
for (int i = 0; i < mBubblesNum; i++)
{
mBubbles[i] = new Bubbles();
mBubbles[i].setX(mRandom.nextInt(mWidth));
mBubbles[i].setRadius(mRandom.nextInt(10));
mBubbles[i].setY(mHeight + mBubbles[i].getRadius());
mBubbles[i].setColor(Bubbles.color[mRandom.nextInt(9)]);
mBubbles[i].setX_Speed(mRandom.nextInt(4) - 2);
mBubbles[i].setY_Speed(-mRandom.nextInt(10) -1);
mBubbles[i].isLive = mRandom.nextBoolean();
}
}
}
public void moveBubbles()
{
if (showSnow)
{
for (int i = 0; i < mBubblesNum; i++)
{
if (!mBubbles[i].isLive)
{
mBubbles[i].setX(mRandom.nextInt(mWidth));
mBubbles[i].setRadius(mRandom.nextInt(3));
mBubbles[i].setY(-mBubbles[i].getRadius());
mBubbles[i].setColor(Color.WHITE);
mBubbles[i].setX_Speed(mRandom.nextInt(4) - 2);
mBubbles[i].setY_Speed(mRandom.nextInt(5)+1);
mBubbles[i].isLive = true;
}
else
{
mBubbles[i].setX(mBubbles[i].getX() + mBubbles[i].getX_Speed());
mBubbles[i].setY(mBubbles[i].getY() + mBubbles[i].getY_Speed());
if ((mBubbles[i].getX() < -mBubbles[i].getRadius()) || (mBubbles[i].getX() > mWidth + mBubbles[i].getRadius())
|| (mBubbles[i].getY() >mHeight +mBubbles[i].getRadius()))
{
mBubbles[i].isLive = false;
}
}
}
}
else
{
for (int i = 0; i < mBubblesNum; i++)
{
if (!mBubbles[i].isLive)
{
mBubbles[i].setX(mRandom.nextInt(mWidth));
mBubbles[i].setRadius(mRandom.nextInt(10));
mBubbles[i].setY(mHeight + mBubbles[i].getRadius());
mBubbles[i].setColor(Bubbles.color[mRandom.nextInt(9)]);
mBubbles[i].setX_Speed(mRandom.nextInt(4) - 2);
mBubbles[i].setY_Speed(-mRandom.nextInt(10)-1);
mBubbles[i].isLive = true;
}
else
{
mBubbles[i].setX(mBubbles[i].getX() + mBubbles[i].getX_Speed());
mBubbles[i].setY(mBubbles[i].getY() + mBubbles[i].getY_Speed());
if ((mBubbles[i].getX() < -mBubbles[i].getRadius()) || (mBubbles[i].getX() > mWidth + mBubbles[i].getRadius())
|| (mBubbles[i].getY() < -mBubbles[i].getRadius()))
{
mBubbles[i].isLive = false;
}
}
}
}
}
public void drawBubbles(Canvas canvas, Paint paint)
{
for (int i = 0; i < mBubblesNum; i++)
{
if (mBubbles[i].isLive)
{
paint.setColor(mBubbles[i]._color);
canvas.drawCircle(mBubbles[i].getX(), mBubbles[i].getY(), mBubbles[i].getRadius(), paint);
}
}
}
public void setWidth(int Width)
{
this.mWidth = Width;
}
public void setHeight(int Height)
{
this.mHeight = Height;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Android动态桌面LiveWallpaper.rar (27个子文件)
Android动态桌面LiveWallpaper
.project 816B
src
jack
wallpaper
Bubbles.java 2KB
LiveWallpaper.java 5KB
BubbleControl.java 5KB
AndroidManifest.xml 784B
res
drawable-ldpi
icon.png 2KB
xml
livepaper.xml 112B
drawable-hdpi
icon.png 4KB
drawable-mdpi
icon.png 3KB
layout
values
strings.xml 115B
.settings
org.eclipse.jdt.core.prefs 203B
assets
gen
jack
wallpaper
R.java 565B
default.properties 449B
.classpath 273B
bin
resources.ap_ 10KB
jack
wallpaper
R$drawable.class 388B
R$attr.class 328B
LiveWallpaper.class 884B
R$xml.class 378B
LiveWallpaper$PaperEngine.class 4KB
LiveWallpaper$PaperEngine$1.class 903B
R.class 459B
R$string.class 386B
Bubbles.class 2KB
BubbleControl.class 3KB
LiveWallpaper.apk 16KB
classes.dex 9KB
共 27 条
- 1
godpower888
- 粉丝: 14
- 资源: 72
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页