Leonids 粒子系统源码分析
来源:互联网 发布:好看的韩国迷你网络剧 编辑:程序博客网 时间:2024/05/17 09:14
https://github.com/plattysoft/Leonids
用第一例子oneshot为例子:
public void onClick(View arg0) {
new ParticleSystem(this, 2, R.drawable.star_pink, 3200)
.setSpeedRange(0.1f, 0.25f) // 速度在这个两值之间,随机取。是角速度啊。
.oneShot(arg0, 2); // arg0为了获得,button的坐标。这个坐标为开始点。
}
所有点都画在ParticleField上了,这是一个view。
mActiveParticles 存放所有点的坐标信息,速度。。。
private void onUpdate(long miliseconds) {
while (((mEmitingTime > 0 && miliseconds < mEmitingTime)|| mEmitingTime == -1) && // This point should emit
!mParticles.isEmpty() && // We have particles in the pool
mActivatedParticles < mParticlesPerMilisecond*miliseconds) { // and we are under the number of particles that should be launched
// Activate a new particle
activateParticle(miliseconds);
Log.e(TAG,"activateParticle");
}
synchronized(mActiveParticles) {
for (int i = 0; i < mActiveParticles.size(); i++) {
Log.e(TAG,"mActiveParticles i:"+i);
boolean active = mActiveParticles.get(i).update(miliseconds);//更新坐标
if (!active) {
Particle p = mActiveParticles.remove(i);
i--; // Needed to keep the index at the right position
mParticles.add(p);
}
}
}
mDrawingView.postInvalidate();
}
private void startAnimator(Interpolator interpolator, long animnationTime) { mAnimator = ValueAnimator.ofInt(0, (int) animnationTime); mAnimator.setDuration(animnationTime); mAnimator.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int miliseconds = (Integer) animation.getAnimatedValue(); onUpdate(miliseconds); } }); mAnimator.addListener(new AnimatorListener() { @Override public void onAnimationStart(Animator animation) {} @Override public void onAnimationRepeat(Animator animation) {} @Override public void onAnimationEnd(Animator animation) { cleanupAnimation(); } @Override public void onAnimationCancel(Animator animation) { cleanupAnimation(); } }); mAnimator.setInterpolator(interpolator); mAnimator.start();}
第二个例子,加速度掉下来。要手工计算 x=v0t+1/2*at^2
mCurrentX = mInitialX+mSpeedX*realMiliseconds+mAccelerationX*realMiliseconds*realMiliseconds;
- Leonids 粒子系统源码分析
- OpenGL烟花粒子系统(含源码)
- OpenGL ES2.0粒子系统(附有源码)
- OpenGL ES2.0粒子系统(附有源码)
- 粒子系统
- 粒子系统
- 粒子系统
- 粒子系统
- 粒子系统
- 粒子系统
- 粒子系统。
- 粒子系统
- 粒子系统
- 粒子系统
- 粒子系统
- 粒子系统
- 粒子系统
- 粒子系统
- JVM性能优化(一)JVM技术入门
- js工具方法
- [leetcode525]Contiguous Array
- Python不使用函数,实现用户登录控制
- rex 文件操作
- Leonids 粒子系统源码分析
- js链接跳转
- 解决jenkins获取${TEST_COUNTS}值为空问题
- android studio 真机调试 点击Run 都是Debug模式 修正方法
- 小程序API接口chooseLocation获取省市区
- POJ 3254 Corn Fields(状压DP)
- Shader学习基础之一(图形流水线)
- JVM性能调优监控工具专题一:JVM自带性能调优工具(jps,jstack,jmap,jhat,jstat,hprof)
- APP性能-电量优化-安装battery historian