Drawing a sprite from bottom left corner

39 views
Skip to first unread message

Samarth Hattangady

unread,
Mar 23, 2016, 1:26:24 AM3/23/16
to HaxeFlixel
Is it possible to draw sprites from bottom left corner?
I am currently using makeGraphic to draw my sprite.

In OpenFL, there is an option to do so using this.graphics.beginFill ... etc, where we can set the x and y coordinates of the sprite to any other point apart from the top left corner.
In some other software, you can do this by setting height and width as negative values.

How can we do this in HaxeFlixel?
Thank you.

Claudio Ficara

unread,
Mar 24, 2016, 3:17:07 PM3/24/16
to HaxeFlixel
When you load a graphic, you can use the params width and height to change its size, by combining this with the offset option, you could draw any section you want.

Alternatively, you can use any graphic (the .png file itself) of any FlxSprite and use it to do another resized sprite, heres my example:

var clone:FlxSprite = new FlxSprite(this.x, this.y);
            clone
.loadGraphic(this.cachedGraphics, false, false, Std.int(this.width), Std.int(this.height * 0.5));

I believe is now just this.cache, have to update. Anyways, I use that to cut in half a sprite, dinamically, so give it a try!
Reply all
Reply to author
Forward
0 new messages