我的粒子開始向上拍攝。在運行時在libgdx中旋轉粒子java
但是,如果您向右拍攝帶有粒子的「咒語」,我想旋轉整個發射器-90度,以便向右拍攝而不是向上拍攝。
如何做到這一點。
這是我的拍攝權和粒子向上爆炸這是奇怪的,所以我希望它在-90度的角度拍攝,如果我拍右像下面的圖片中
我的粒子開始向上拍攝。在運行時在libgdx中旋轉粒子java
但是,如果您向右拍攝帶有粒子的「咒語」,我想旋轉整個發射器-90度,以便向右拍攝而不是向上拍攝。
如何做到這一點。
這是我的拍攝權和粒子向上爆炸這是奇怪的,所以我希望它在-90度的角度拍攝,如果我拍右像下面的圖片中
你可以獲得一個效果控制器並將旋轉設置爲該效果。控制器本身就是一個發射器。此外,您可以通過在運行時設置旋轉來旋轉整個效果。
使用給定的四元數調用Effect.rotate(Quaternion rotation);
(See this),您需要在actor中更新自己並調用rotate。但是旋轉本身受控制器/發射器的更新影響!
如果你想(1個或2個發射極不喜歡所有)旋轉效果的部分按名稱獲取與findController(string name)
klick here發射器(你在GUI中設置),只是設置旋轉如上的Controller 。
我幾乎不會推薦不要使用射向一個方向的效果! Insead我會使用一個沒有朝某個方向移動的效果,然後移動效果,最後效果相同,但是您可以決定朝哪個方向移動。我的意思很小的例子:
public class SimpleRocket extends Firework {
private ParticleEffect boom, thrust;
private Vector2 direction;
private boolean secondeffect = false;
public SimpleRocket(FireworkTycoonMain main) {
super(main);
boom = new ParticleEffect();
boom.load(Gdx.files.internal("effect/firework.p"),
main.manager.getAtlas());
thrust = new ParticleEffect();
thrust.load(Gdx.files.internal("effect/goldregen.p"),
main.manager.getAtlas());
thrust.start();
}
public void init(float mass, float acceleration, Vector2 startdirection,
int flytime) {
this.thrust.setDuration(flytime);
this.mass = mass;
this.acceleration = acceleration;
direction = startdirection;
direction.nor();
}
@Override
public void act(float delta) {
final float alpha = direction.getAngleRad();
final float y = (float) (Firework.GRAVITY * mass + acceleration
* Math.sin(alpha) * delta * delta);
final float x = (float) (acceleration * Math.cos(alpha) * delta * delta + wind);
direction.x = x;
direction.y = y;
direction.nor();
setPosition(getX() + x, getY() + y);
boom.setPosition(getX(), getY());
thrust.setPosition(getX(), getY());
thrust.update(delta);
boom.update(delta);
if (thrust.isComplete() && !secondeffect) {
main.sound.playPeng();
boom.start();
secondeffect = true;
}
}
@Override
public void draw(Batch batch, float alpha) {
if (!boom.isComplete()) {
boom.draw(batch);
}
if (!thrust.isComplete()) {
thrust.draw(batch);
}
}
}
如果你simmelar了廣泛的影響(不是一個點),它可能看起來像你的效果,但是隻要你喜歡,你可以四處移動它。
請發佈您到目前爲止嘗試過的代碼。 –
@RohitGupta theres沒有代碼顯示,因爲我找不到任何代碼來完成我將張貼正在發生的事情的圖像 – Temo
我不認爲這是支持的。 – Tenfour04