0

I would like to attach a line drawed with canvas to a Scene. I'm using andengine library.

I know that andengine provides line objects that can be draw and attached to a scene, but this is not an option for me because i'm trying to make a pretty glow line.

This is how a andengine line is attached to the scene.

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 enter image description here and as you can see, it dont seems pretty good or maybe is the fact that i am not applying proper styles, i'll be happy of you notified me.

But if i try with canvas, it looks a perfect glow line. enter image description here

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);
    }
}

I wanted the perfect glow line to be attached to my scene. I'm doing that way because i'm also using OnClickListener with sprites objects. Any suggestion or help would help me a lot. Thanks.

Sandeep R
  • 2,284
  • 3
  • 25
  • 51
Alex
  • 7
  • 6
  • Not sure of it is a good approach, but I would start from this: http://stackoverflow.com/questions/8940673/displaying-ad-in-andengine Here you create View (BannerView) and attach it to frameLayout. You also have a View class so it might work similarly. Remember that you can override onSetContentView() in your main activity class. – Łukasz Motyczka Jun 08 '15 at 08:55
  • Also you may look into my approach to Ads: http://stackoverflow.com/questions/29332639/how-to-display-admob-smartbanner-exactly-on-the-bottom-of-the-screen-while-using I think that apporach is mainly the same. – Łukasz Motyczka Jun 08 '15 at 09:00
  • 1
    I thank to you, that will help a lot later. I think I found what I was looking for here https://github.com/nicolasgramlich/AndEngineExamples/blob/GLES2/src/org/andengine/examples/CanvasTextureCompositingExample.java – Alex Jun 13 '15 at 02:32
  • Can you please post ,How did you achieve the effect shown in the image.pls..? – Sandeep R Nov 18 '16 at 08:20

0 Answers0