我想将一条用画布绘制的线附加到场景中。我使用的是dedengine库。
我知道andengine提供了可以绘制并附加到场景的线对象,但这对我来说不是一个选项,因为我试图制作漂亮的发光线。
这是andengine线附加到场景的方式。
public class MainActivity extends SimpleBaseGameActivity implements OnClickListener {
//--Declaration and implementation of all overrides, etc.--
@Override
protected Scene onCreateScene() {
final Line line = new Line(50,75,CAMERA_WIDTH,89,20,vbom);
line.setColor(248, 255, 255, 255);
line.setLineWidth(5f);
final Line line2 = new Line(50,75,CAMERA_WIDTH,89,50,vbom);
line2.setColor(235, 74, 138, 255);
line2.setLineWidth(10f);
scene.attachChild(line2);
scene.attachChild(line);
return scene;
}
}
This is how it looks like 正如你所看到的那样,它看起来不太好,或者可能是因为我没有应用合适的款式,我很高兴你通知我。
But if i try with canvas, it looks a perfect glow line.
public class DrawingView extends View {
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawColor(Color.BLACK);
Paint _paintSimple = new Paint();
_paintSimple.setAntiAlias(true);
_paintSimple.setDither(true);
_paintSimple.setColor(Color.argb(248, 255, 255, 255));
_paintSimple.setStrokeWidth(5f);
_paintSimple.setStyle(Paint.Style.STROKE);
_paintSimple.setStrokeJoin(Paint.Join.ROUND);
_paintSimple.setStrokeCap(Paint.Cap.ROUND);
Paint _paintBlur = new Paint();
_paintBlur.set(_paintSimple);
_paintBlur.setColor(Color.argb(235, 74, 138, 255));
_paintBlur.setStrokeWidth(10f);
_paintBlur.setMaskFilter(new BlurMaskFilter(15, BlurMaskFilter.Blur.NORMAL));
canvas.drawLine(100, 150, 400, 150, _paintBlur);
canvas.drawLine(100, 150, 400, 150, _paintSimple);
}
}
我希望将完美的发光线贴在我的场景上。我这样做是因为我也在使用带有精灵对象的OnClickListener。任何建议或帮助都会对我有所帮助。感谢。