Draw a rope or textured line

118 views
Skip to first unread message

Tembac

unread,
Dec 1, 2014, 7:47:05 PM12/1/14
to haxef...@googlegroups.com
Hello community,

I want to know if it is possible to draw a rope: A line that can be of any length and angle but it has the texture of a rope. 

I'm using the sprite utils to draw a line of a solid color now but I want to be able to make it look like a rope. Like this:



SruloArt

unread,
Dec 3, 2014, 4:21:07 PM12/3/14
to
It's possible with Nape or the new (dev branch) drawTriangles related classes (just search how people did it with Flash and copy-paste-adjust to HaxeFlixel). It's pretty cool to finally have a real "texture" you can manipulate with vertices on HaxeFlixel...so it would be really nice to see your results if you choose to use it, I can find a use for a FlxRope class :)

Tembac

unread,
Dec 3, 2014, 8:39:14 PM12/3/14
to haxef...@googlegroups.com
Thanks, I'm not using the dev branch because I need to be sure the game is stable. I hope the new Haxeflixel is released soon. I'm seeing a lot of cool things being fixed and implemented.

The "physics" part of a rope is exemplified on the nape demo with the balloons. But I don't need a real physics rope but a line with texture. I'll wait the HaxeFlixel release if there is no other option.


On Wednesday, December 3, 2014 6:21:07 PM UTC-3, SruloArt wrote:
It's possible with Nape or the new (dev branch) drawTriangles related classes (just search how people did it with Flash and copy-paste-adjust to HaxeFlixel). It's pretty cool to finally have a real "texture" you can manipulate with vertices on HaxeFlixel...so it would be really nice to see your results if you choose to use it, I can find a use for a FlxRope class :)

On Tuesday, December 2, 2014 2:47:05 AM UTC+2, Tembac wrote:

Tembac

unread,
Dec 28, 2014, 3:02:13 AM12/28/14
to haxef...@googlegroups.com
This is something similar to what I want. I leave it here just in case it helps anyone else:

class RopeSegment extends FlxSprite
{


 
public function new(X:Float=0, Y:Float=0, ?SimpleGraphic:Dynamic)
 
{
 
super(X, Y);
 
 makeGraphic
(100, 10);
 
//loadGraphic("assets/images/rope.png");
 initialSetup
();
 
}
 
 
public function initialSetup():Void
 
{
 
//cambia el centro de giro.
 origin
.set(0, height * .5);
 
}
 
 
public function setLinesExtremes(p1:FlxPoint, p2:FlxPoint):Void
 
{
 p1
.add(0, -height * .5);
 p2
.add(0, -height * .5);
 
 angle
= FlxAngle.getAngle(p1, p2) -90;
 
 setPosition
(p1.x, p1.y);
 
 
var dist = FlxMath.getDistance(p1, p2);
 
 scale
.x = dist / width;
 
}
 
}

Tembac

unread,
Dec 28, 2014, 3:35:40 AM12/28/14
to haxef...@googlegroups.com
Ups. On some angles it is not working well. Anybody knows why?

Tembac

unread,
Dec 28, 2014, 7:56:39 PM12/28/14
to haxef...@googlegroups.com
The problem was on the getAngle function of the release Haxeflixel. Luckily I checked that it is fixed on dev :D

I hope dev is realeased soon. It seems to improve a lot!
Reply all
Reply to author
Forward
0 new messages