本文整理匯總了Java中com.badlogic.gdx.graphics.g2d.ParticleEffect類的典型用法代碼示例。如果您正苦於以下問題:Java ParticleEffect類的具體用法?Java ParticleEffect怎麽用?Java ParticleEffect使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ParticleEffect類屬於com.badlogic.gdx.graphics.g2d包,在下文中一共展示了ParticleEffect類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadParticleEffects
import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入依賴的package包/類
private void loadParticleEffects(TiledMap data, String atlasname) {
MapObjects objects = data.getLayers().get("preload").getObjects();
String ppcheck = "Particle";
for (MapObject o : objects) {
String name = o.getName();
MapProperties properties = o.getProperties();
String type = properties.get("type", String.class);
if (type != null && type.equals(ppcheck)) {
String file = properties.get("particle_file", String.class);
if (file != null) {
game.loadParticleEffect(file, atlasname);
game.getAssetManager().finishLoading();
if (!particle_effects.containsKey(name)) {
ParticleEffect pe = game.getParticleEffect(file);
pe.setEmittersCleanUpBlendFunction(false);
pvalues.add(KyperBoxGame.PARTICLE_FOLDER + KyperBoxGame.FILE_SEPARATOR + file);
particle_effects.put(name, new ParticleEffectPool(pe, 12, 48));
}
}
}
}
}
示例2: act
import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入依賴的package包/類
@Override
public void act(float delta){
battleTimer = (battleTimer + delta)%60;
if( damageValLabel.isVisible() && damageValLabel.getY() < this.getHeight()){
damageValLabel.setY(damageValLabel.getY()+5);
}
if( battleShakeCam != null && battleShakeCam.isCameraShaking() ){
Vector2 shakeCoords = battleShakeCam.getNewShakePosition();
_image.setPosition(shakeCoords.x, shakeCoords.y);
}
for( int i = 0; i < _effects.size; i++){
ParticleEffect effect = _effects.get(i);
if( effect == null ) continue;
if( effect.isComplete() ){
_effects.removeIndex(i);
effect.dispose();
}else{
effect.update(delta);
}
}
super.act(delta);
}
示例3: getParticleEffect
import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入依賴的package包/類
public static ParticleEffect getParticleEffect(ParticleEffectType particleEffectType, float positionX, float positionY){
ParticleEffect effect = new ParticleEffect();
effect.load(Gdx.files.internal(particleEffectType.getValue()), Gdx.files.internal(SFX_ROOT_DIR));
effect.setPosition(positionX, positionY);
switch(particleEffectType){
case CANDLE_FIRE:
effect.scaleEffect(1.6f);
break;
case LANTERN_FIRE:
effect.scaleEffect(.6f);
break;
case LAVA_SMOKE:
effect.scaleEffect(1.6f);
break;
case WAND_ATTACK:
effect.scaleEffect(4.0f);
break;
default:
break;
}
effect.start();
return effect;
}
示例4: Shoot
import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入依賴的package包/類
public Shoot(String nameTexture, int x, int y, GameObject shooter, ParticleEffect shootEffect, ParticleEffect destroyEffect, String shootFX) {
super(nameTexture,x,y);
this.shooter = shooter;
shocked = false;
originalShootPosition = new Vector2(x,y);
//Creamos los efectos de partículas si no vienen nulos
if (shootEffect != null) {
this.shootEffect = shootEffect;
shootEffect.start();
}
if (destroyEffect != null) {
this.destroyEffect = destroyEffect;
destroyEffect.start();
}
this.shootFX = shootFX;
}
示例5: Enemy
import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入依賴的package包/類
public Enemy(String textureName, int x, int y, int vitality, ParticleEffect destroyEffect) {
super(textureName, x, y);
initialPosition = new Vector2(x,y);
this.vitality = vitality;
deletable = false;
this.destroyEffect = destroyEffect;
timeToFlick = 0;
timeForInvisible = RANGE_INVISIBLE_TIMER;
targettedByShip = false;
if(this.destroyEffect != null){
this.destroyEffect.getEmitters().first().setPosition(this.getX() + this.getWidth()/2, this.getY() + this.getHeight()/2);
this.destroyEffect.start();
}
}
示例6: Car
import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入依賴的package包/類
public Car(String name, String lane, Texture texture, Vector2 pos, Vector2 direction) {
super(texture, pos, direction);
this.eType = 1;
if(name.equals("CAR1")){
carWidth = TextureManager.CAR1.getWidth();
carHeight = TextureManager.CAR1.getHeight();
}else if(name.equals("CAR2")){
carWidth = TextureManager.CAR2.getWidth();
carHeight = TextureManager.CAR2.getHeight();
}
smokeEffect = new ParticleEffect();
smokeEffect.load(Gdx.files.internal("effects/car_smoke_1.p"), Gdx.files.internal("effect_img"));
smokeEffect.setPosition(this.pos.x + carWidth / 2, this.pos.y + carHeight / 10 );
smokeEffect.start();
}
示例7: addParticleEffectActuator
import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入依賴的package包/類
public ActuatorEntity addParticleEffectActuator(ParticleEffect effect,
boolean autoStart, float locaPosX, float locaPosY) {
ParticleEffectActuator component = (ParticleEffectActuator) recoverComponent(ActuatorComponentsLookup.ParticleEffectActuator);
if (component == null) {
component = new ParticleEffectActuator(effect, autoStart, locaPosX,
locaPosY);
} else {
component.particleEffect = effect;
component.actuator = (indexOwner) -> {
GameEntity owner = Indexed.getInteractiveEntity(indexOwner);
RigidBody rc = owner.getRigidBody();
Transform transform = rc.body.getTransform();
effect.setPosition(transform.getPosition().x + locaPosX,
transform.getPosition().y + locaPosY);
effect.update(Gdx.graphics.getDeltaTime());
if (autoStart && effect.isComplete())
effect.start();
};
}
addComponent(ActuatorComponentsLookup.ParticleEffectActuator, component);
return this;
}
示例8: replaceParticleEffectActuator
import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入依賴的package包/類
public ActuatorEntity replaceParticleEffectActuator(ParticleEffect effect,
boolean autoStart, float locaPosX, float locaPosY) {
ParticleEffectActuator component = (ParticleEffectActuator) recoverComponent(ActuatorComponentsLookup.ParticleEffectActuator);
if (component == null) {
component = new ParticleEffectActuator(effect, autoStart, locaPosX,
locaPosY);
} else {
component.particleEffect = effect;
component.actuator = (indexOwner) -> {
GameEntity owner = Indexed.getInteractiveEntity(indexOwner);
RigidBody rc = owner.getRigidBody();
Transform transform = rc.body.getTransform();
effect.setPosition(transform.getPosition().x + locaPosX,
transform.getPosition().y + locaPosY);
effect.update(Gdx.graphics.getDeltaTime());
if (autoStart && effect.isComplete())
effect.start();
};
}
replaceComponent(ActuatorComponentsLookup.ParticleEffectActuator,
component);
return this;
}
示例9: addEffect
import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入依賴的package包/類
public void addEffect(String name, Vector2 position, float angle){
logger.debug("Creating effect: " + name);
ParticleEffect effect = App.assets.getEffect(name);
if (effect == null) {
logger.error("Couldn't create particle effect: " + name);
return;
}
ParticleEffect e = new ParticleEffect(effect);
for (ParticleEmitter emitter : e.getEmitters()){
float a1 = emitter.getAngle().getHighMin(),
a2 = emitter.getAngle().getHighMax();
emitter.getRotation().setHighMin(a1 + angle);
emitter.getRotation().setHighMax(a2 + angle);
}
e.setPosition(position.x * App.engine.PIXELS_PER_METER, position.y * App.engine.PIXELS_PER_METER);
e.start();
effects.add(e);
}
示例10: getOrLoad
import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入依賴的package包/類
@Override
public ParticleEffect getOrLoad(final String id) {
final String[] data = Strings.split(id, '$');
if (data.length == 0) {
throwUnknownPathException();
}
final String path = determinePath(data[0]);
getIdsToPaths().put(id, path);
final AssetManager assetManager = getAssetManager();
if (assetManager.isLoaded(path)) {
return assetManager.get(path, getType());
}
if (data.length > 1) {
final String atlasName = TextureAtlasProvider.getTextureAtlasPath(data[1]);
final ParticleEffectParameter parameters = new ParticleEffectParameter();
parameters.atlasFile = atlasName;
assetManager.load(path, ParticleEffect.class, parameters);
} else {
assetManager.load(path, ParticleEffect.class);
}
return null;
}
示例11: ParticleEffectPools
import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入依賴的package包/類
public ParticleEffectPools() {
logger = new Logger(TAG, Env.debugLevel);
logger.info("initialising");
pools = new ObjectMap<String, ParticleEffectPool>();
try {
JsonReader reader = new JsonReader();
JsonValue root = reader.parse(Gdx.files.internal(PARTICLES_FILE));
JsonIterator particlesIt = root.iterator();
while (particlesIt.hasNext()) {
JsonValue particleValue = particlesIt.next();
String effectName = particleValue.asString();
logger.info("loading " + effectName);
ParticleEffect effect = new ParticleEffect();
effect.load(Gdx.files.internal(effectName), Gdx.files.internal(PARTICLES_FOLDER));
pools.put(effectName, new ParticleEffectPool(effect,
Env.particlePoolInitialCapacity,
Env.particlePoolMaxCapacity));
}
}
catch (Exception e) {
logger.error("failed to list directory " + PARTICLES_FILE);
}
}
示例12: AssetManager
import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入依賴的package包/類
/** Creates a new AssetManager with all default loaders. */
public AssetManager (FileHandleResolver resolver) {
setLoader(BitmapFont.class, new BitmapFontLoader(resolver));
setLoader(Music.class, new MusicLoader(resolver));
setLoader(Pixmap.class, new PixmapLoader(resolver));
setLoader(Sound.class, new SoundLoader(resolver));
setLoader(TextureAtlas.class, new TextureAtlasLoader(resolver));
setLoader(Texture.class, new TextureLoader(resolver));
setLoader(Skin.class, new SkinLoader(resolver));
setLoader(ParticleEffect.class, new ParticleEffectLoader(resolver));
setLoader(PolygonRegion.class, new PolygonRegionLoader(resolver));
setLoader(I18NBundle.class, new I18NBundleLoader(resolver));
setLoader(Model.class, ".g3dj", new G3dModelLoader(new JsonReader(), resolver));
setLoader(Model.class, ".g3db", new G3dModelLoader(new UBJsonReader(), resolver));
setLoader(Model.class, ".obj", new ObjLoader(resolver));
executor = new AsyncExecutor(1);
}
示例13: FireWorksLayer
import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入依賴的package包/類
public FireWorksLayer(GameGrid gameGrid) {
super();
gameGrid.events().register(this);
TutorialEngine.instance().eventBus().register(this);
AchievementEngine.instance().eventBus().register(this);
ParticleEffect particleEffect = new ParticleEffect();
particleEffect.load(Gdx.files.internal("particles/firework.p"), Gdx.files.internal("particles"));
Set<float[]> colors = Sets.newHashSet();
colors.add(makeParticleColorArray(Color.WHITE, Color.RED, Color.ORANGE));
colors.add(makeParticleColorArray(Color.WHITE, Color.BLUE, Color.GREEN));
colors.add(makeParticleColorArray(Color.WHITE, Color.YELLOW, Color.PINK));
colors.add(makeParticleColorArray(Color.WHITE, Color.PINK, Color.MAGENTA));
colors.add(makeParticleColorArray(Color.WHITE, Color.BLUE, Color.CYAN));
colorsIterator = Iterators.cycle(colors);
worldBounds = new Rectangle();
for (int i = 0; i < 10; i++) {
addChild(new ParticleEffectManager(new ParticleEffect(particleEffect), colorsIterator, worldBounds));
}
}
示例14: match
import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入依賴的package包/類
@Override
public boolean match(FileHandle file) {
boolean result = file.extension().equals("p");
if(result) {
Engine.getAssetManager().load(file.path().replace("\\", "/"),ParticleEffect.class);
return result;
}
result = file.extension().equals("pp");
if(result) {
ParticleEffectParameter parameter = new ParticleEffectParameter();
parameter.atlasFile = file.pathWithoutExtension().replace("\\", "/")+".atlas";
Engine.getAssetManager().load(file.path().replace("\\", "/"),ParticleEffect.class,parameter);
return result;
}
return false;
}
示例15: AchievementButton
import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入依賴的package包/類
public AchievementButton(TextureAtlas hudAtlas, AchievementEngine achievementEngine) {
super(hudAtlas.findRegion("achievements"), Colors.ICS_BLUE);
activeAnimation = new Animation(ANIMATION_DURATION, hudAtlas.findRegions("achievements-active"));
nextAnimationTime = 0;
particleEffect = new ParticleEffect();
particleEffect.load(Gdx.files.internal("particles/sparkle.p"), Gdx.files.internal("particles"));
addListener(new VibrateClickListener() {
public void onClick(InputEvent event, float x, float y) {
new AchievementListView(getStage()).show();
}
});
setVisible(false);
}