Back to project page linevslinerpg.
The source code is released under:
Apache License
If you think the Android project linevslinerpg listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.jmpmain.lvslrpg.particles; //from w ww . ja v a 2 s.c om import com.jmpmain.lvslrpg.entities.Item; import com.jmpmain.lvslrpg.entities.Item.ItemType; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; public class ItemParticle extends Particle { public long createTime; private Paint paint; private Bitmap icon; public float x; public float y; float xVelocity; float yVelocity; public ItemType type; public ItemParticle(int x, int y, ItemType t, long time){ destroy = false; createTime = time; paint = new Paint(); paint.setARGB(255, 255, 255, 255); icon = Item.GetItemIcon(t); this.x = x; this.y = y; xVelocity = (float) (Math.random() - 0.5)*10; yVelocity = (float) (Math.random() - 0.5)*10; type = t; } @Override public void update(long time) { if(time - createTime >= 750){ destroy = true; return; } paint.setAlpha(Math.min(255, 255 - (int)(255.0f*(1 - (float)(time - createTime)/1000.0f)))); x += xVelocity; y += yVelocity; } @Override public void draw(Canvas canvas) { canvas.drawBitmap(icon, x, y, paint); } }