0

作为我游戏的一部分,我在舞台上移动汽车并尝试将前灯放在同一位置。我正在对 CAR 设置操作,以便 CAR 的位置更新将由 scene2d.actions.Actions 处理。这是我用来设置灯光的代码:

rayHandler.setCombinedMatrix(stage.getCamera().combined);
rayHandler.useCustomViewport(viewport.getScreenX(), viewport.getScreenY(),
                viewport.getScreenWidth(), viewport.getScreenHeight());
coneLight = new ConeLight(rayHandler, 50, Color.YELLOW, 150, 400, 150,0,45);

但问题是,它需要定位灯的位置,现在要获得汽车前灯的位置很棘手(或者我错过了全世界都知道的东西),因为汽车可以在任何方向,有没有办法给演员加光?或者我们应该总是使用计算光的位置

就像是 actor.getX() + cosDeg(actor.direction())*length;

例如看图片 在此处输入图像描述

4

1 回答 1

0

获取精灵顶点的位置解决了这个问题

import static com.badlogic.gdx.graphics.g2d.Batch.X2;
import static com.badlogic.gdx.graphics.g2d.Batch.X3;
import static com.badlogic.gdx.graphics.g2d.Batch.Y2;
import static com.badlogic.gdx.graphics.g2d.Batch.Y3;

... #somewhere in render method.
coneLight.setPosition(sprite.getVectors()[X2], sprite.getVectors()[Y2]);
于 2018-03-05T15:30:12.250 回答