wlzboy
February 21, 2020, 3:40am
#1
base on 8.9.6 ,use the graphics.curveTo
eg:
var spr:Sprite = new Sprite();
spr.x=100;
spr.y=100;
spr.graphics.lineStyle(1,0,1);
spr.graphics.moveTo(0,0);
spr.graphics.curveTo(100, -100, 200, 0);
spr.graphics.moveTo(0,0);
spr.graphics.curveTo(100, 100, 200, 0);
this.addChild(spr);
obscure
February 25, 2020, 10:49am
#2
I’m not sure what your issue is - I’d say it’s the expected behaviour since you’re just drawing two curves.
To have that particular third line you would need to draw an additional line to the origin after the two curves have been drawn e.g.
spr.graphics.lineStyle(1, 0, 1);
spr.graphics.moveTo(0, 0);
spr.graphics.curveTo(100, -100, 200, 0);
spr.graphics.moveTo(0, 0);
spr.graphics.curveTo(100, 100, 200, 0);
spr.graphics.lineTo(0, 0);
wlzboy
March 4, 2020, 8:57am
#3
When I want to draw a coil, Like this use the AS3 .
But I always have a horizontal line in the middle.Use openfl 8.9.6
Typescript code eg:
var spr:Sprite = new Sprite();
spr.x=100;
spr.y=100;
spr.graphics.lineStyle(1,0,1);
spr.graphics.moveTo(0,0);
spr.graphics.curveTo(100, -100, 200, 0);
spr.graphics.moveTo(0,0);
spr.graphics.curveTo(100, 100, 200, 0);
this.addChild(spr);
I had a similar issue, where the “moveTo” command behaved differently between Flash & OpenFL.
Here is a workaround for your case :
var spr:Sprite = new Sprite();
spr.x=100;
spr.y=100;
spr.graphics.lineStyle(1,0,1);
spr.graphics.moveTo(0,0);
spr.graphics.curveTo(100, -100, 200, 0);
spr.graphics.curveTo(100, 100, 0, 0);
this.addChild(spr);
wlzboy
March 5, 2020, 6:43am
#6
Yes,It’s work!,thank you!
1 Like