Getting started tutorial - UI : error

50 views
Skip to first unread message

s c

unread,
Mar 25, 2016, 5:59:28 AM3/25/16
to HaxeFlixel


Hi guys,

It seems the FlxSprite class no longer has a drawRect() method. So, the class HUD no longer builds ...

private var _sprBack:FlxSprite;
...

public function new()
{
   
super();
   _sprBack
= new FlxSprite().makeGraphic(FlxG.width, 20, FlxColor.BLACK);
   _sprBack
.drawRect(0, 19, FlxG.width, 1, FlxColor.WHITE);   // ERROR
   
...
}


Any ideas for a workaround ?
Thanks !!!

Seb Jones

unread,
Mar 25, 2016, 7:47:13 AM3/25/16
to HaxeFlixel
drawRect() isn't actually in the FlxSprite class, but in the FlxSpriteUtil class. Add this line below your imports:

using flixel.util.FlxSpriteUtil;

and it will work.

You can read more about how this works here.

s c

unread,
Mar 25, 2016, 8:40:16 AM3/25/16
to HaxeFlixel
Thank you very much for pointing me to the FlxSpriteUtil class !
I have it working now by doing this :


import flixel.FlxSprite;
import flixel.util.FlxSpriteUtil;
...
class HUD extends FlxTypedGroup<FlxSprite>
{

   
private var _sprBack:FlxSprite;
   
...
   
public function new()
   
{
     
super();

      _sprBack
= new FlxSprite().makeGraphic(FlxG.width, 15, FlxColor.BLACK);
     
FlxSpriteUtil.drawLine(_sprBack, 0, 14, FlxG.width, 14, { color: FlxColor.WHITE, thickness: 1 });
     
...
   
}
   
...
}


Your link to "static extensions" is also very much appreciated (but a bit over my head atm :-) ) I definitely want to start reading the Haxe documentation from the start.

Q : maybe someone needs to update the tutorial ???
Reply all
Reply to author
Forward
0 new messages