reworkd adventure main call

added particle effects
This commit is contained in:
Grimm
2022-08-26 16:43:36 +02:00
parent 1a112ae7c6
commit f8710974e3
4 changed files with 31 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.graphics.g2d.ParticleEmitter;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Actor;
@@ -35,17 +36,35 @@ public class MapActor extends Actor {
final int objectId;
Array<CurrentEffect> effects=new Array<>();
public void playEffect(String path,Vector2 offset,boolean overlay)
public void playEffect(String path,float duration,boolean overlay,Vector2 offset)
{
ParticleEffect effect = new ParticleEffect();
effect.load(Config.instance().getFile(path),Config.instance().getFile(path).parent());
effect.getEmitters().first().setPosition(offset.x,offset.y);
effects.add(new CurrentEffect(effect,offset,overlay));
if(duration!=0)//ParticleEffect.setDuration uses an integer for some reason
{
int i = 0;
for(int n = effect.getEmitters().size; i < n; ++i) {
ParticleEmitter emitter = effect.getEmitters().get(i);
emitter.setContinuous(false);
emitter.duration = duration;
emitter.durationTimer = 0.0F;
}
}
effect.start();
}
public void playEffect(String path,float duration,boolean overlay)
{
playEffect(path,duration,overlay,Vector2.Zero);
}
public void playEffect(String path,float duration)
{
playEffect(path,duration,false,Vector2.Zero);
}
public void playEffect(String path)
{
playEffect(path,Vector2.Zero,false);
playEffect(path,0,false,Vector2.Zero);
}
public MapActor(int objectId)
{
@@ -112,8 +131,7 @@ public class MapActor extends Actor {
{
CurrentEffect effect=effects.get(i);
effect.effect.update(delta);
effect.effect.setPosition(getX()+effect.offset.x,getY()+effect.offset.y);
effect.effect.setPosition(getX()+getHeight()/2+effect.offset.x,getY()+getWidth()/2+effect.offset.y);
if(effect.effect.isComplete())
{
effects.removeIndex(i);

View File

@@ -50,7 +50,8 @@ public class TileMapScene extends HudScene {
}
stage.act(Gdx.graphics.getDeltaTime());
hud.act(Gdx.graphics.getDeltaTime());
if (autoheal) { //todo add simple bg animation or effect
if (autoheal) { //todo add better effect
stage.GetPlayer().playEffect("particle_effects/Particle Park Hallucinogen.p",2);
SoundSystem.instance.play(SoundEffectType.Enchantment, false);
autoheal = false;
}

View File

@@ -111,7 +111,7 @@ public static ConsoleCommandInterpreter getInstance()
int x = Integer.parseInt(s[0]);
int y = Integer.parseInt(s[1]);
WorldStage.getInstance().setPosition(new Vector2(x,y));
WorldStage.getInstance().player.playEffect("particle_effects/Particle Park Fireworks.p");
WorldStage.getInstance().player.playEffect("particle_effects/Particle Park Fireworks.p",10);
return "teleport to ("+s[0]+","+s[1]+")";
} catch (Exception e) {
return "Exception occured, Invalid input";
@@ -123,7 +123,7 @@ public static ConsoleCommandInterpreter getInstance()
if(poi==null)
return "PoI " + s[0] + " not found";
WorldStage.getInstance().setPosition(poi.getPosition());
WorldStage.getInstance().player.playEffect("particle_effects/Particle Park Laser.p");
WorldStage.getInstance().player.playEffect("particle_effects/Particle Park Laser.p",10);
return "Teleported to " + s[0] + "(" + poi.getPosition() + ")";
});
registerCommand(new String[]{"spawn","enemy"}, s -> {

View File

@@ -7,9 +7,9 @@
"automapping.whileDrawing": false,
"expandedProjectPaths": [
"map/main_story",
"map",
"obj",
"tileset",
"obj"
"map"
],
"file.lastUsedOpenFilter": "All Files (*)",
"fileStates": {
@@ -2188,8 +2188,8 @@
"scale": 1.5,
"selectedLayer": 4,
"viewCenter": {
"x": 840.6666666666667,
"y": 323.6666666666667
"x": -80,
"y": 443.6666666666666
}
},
"map/main_story/swamp_capital.tmx": {