Make a sprite have the screen width

126 views
Skip to first unread message

dexxz

unread,
Sep 26, 2015, 9:30:44 AM9/26/15
to HaxeFlixel
Hello!

I'm new to HaxeFlixel but I have some experience with OpenFL. I want to set the width of my sprite to be the width of the screen. In OpenFL I would do this using sprite.width = Lib.current.stage.stageWidth. But I don't know how to do this in HaxeFlixel.

So if you know how to do this, please help me!

Andrei Regiani

unread,
Sep 26, 2015, 9:56:57 AM9/26/15
to HaxeFlixel
Try this

var scaleRatio:Float = FlxG.width / sprite.width;
sprite
.scale.set(scaleRatio, scaleRatio);

dexxz

unread,
Sep 26, 2015, 1:18:03 PM9/26/15
to haxef...@googlegroups.com
This makes the sprite fill almost all the width but there is still 1/4 of the sprite width left unfilled.

SARFEX

unread,
Sep 26, 2015, 6:32:02 PM9/26/15
to haxef...@googlegroups.com
You can use sprite.width = FlxG.stage.stageWidth
Reply all
Reply to author
Forward
0 new messages