自己整理的粒子系统管理(是不是太简单了?)

自己整理的粒子系统管理,是不是太简单了?

LibParticle.java

package game.pak;

import java.util.ArrayList;

import android.util.Log;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.graphics.g2d.ParticleEffectPool;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class LibParticle {
 
 public static SpriteBatch ParticleBatch;
 
 //   BitmapFont bf;
 public static   ParticleEffect particle;
 public static ParticleEffect tem;
 public static ParticleEffectPool particlepool;
 public static ArrayList<ParticleEffect> particlelist;
 public static float initX=0;
 public static float initY=0;
 
 public static float ParticleX=0;
 public static float ParticleY=0;
 
 public static float XX=0;
 public static float YY=0;
 
 
   public LibParticle(SpriteBatch batch,String resource){
    ParticleBatch=batch;
    particle = new ParticleEffect();
    particle.load(Gdx.files.internal(resource/*"test.p"*/), Gdx.files.internal(""));
    particlepool=new ParticleEffectPool(particle, 5, 10);
    particlelist=new ArrayList<ParticleEffect>();  
 }
 
 //增加粒子
 public static void addParticle(float x,float y){
  initX=x;
  initY=y; 
  tem=particlepool.obtain();
  tem.setPosition(x,800-y);
  particlelist.add(tem); 
 }

 //绘制
 public void drawParticle(){
  ParticleBatch.begin();  
  float aa=Gdx.graphics.getDeltaTime();
        for(int i=0;i<particlelist.size();i++){
        particlelist.get(i).draw(ParticleBatch, Gdx.graphics.getDeltaTime());
        }
        ParticleBatch.end();
 }
 
 public void set_position(float x,float y){  
  this.ParticleX=x;
  this.ParticleY=Gdx.graphics.getHeight()-y;
   for(int i=0;i<particlelist.size();i++){
       particlelist.get(i).setPosition(ParticleX,ParticleY);
   }
 }
 
 //释放
 public void disParticle(){
  ParticleEffect temparticle;
        for(int i=0;i<particlelist.size();i++){
         temparticle=particlelist.get(i);
      if(temparticle.isComplete()){
       particlelist.remove(i);
      }
        }
 }

}

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值