Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlxSprite Load Graphic width vs tile width #650

Closed
gltovar opened this issue Sep 24, 2013 · 1 comment
Closed

FlxSprite Load Graphic width vs tile width #650

gltovar opened this issue Sep 24, 2013 · 1 comment

Comments

@gltovar
Copy link

gltovar commented Sep 24, 2013

So I'm in the middle of trying to figure out why I can't extends a FlxUIButton and construct it with a specific 9 slice button graphic and change the size immediately afterwards.

I've traced my self to a spot in FlxSprite loadGraphic which has the following lines:

if (!Std.is(Graphic, TextureRegion))
{
region = new Region(0, 0, Width, Height);
region.width = cachedGraphics.bitmap.width;
region.height = cachedGraphics.bitmap.height;
}

so In Region.hx it constructs as such:
new(startX:Int = 0, startY:Int = 0, tileWidth:Int = 0, tileHeight:Int = 0,

So when I do:
(in an extended FlxUIButton constructor)

this.loadGraphicSlice9( ["assets/gfx/ui/buttons/button_blue.png"], 18, 18, ["6,6,11,11"] );
this.resize( 200, 100 );

the FlxSprite.loadGraphic's Width == 200, Height == 100
and cachedGraphics.bitmap.width == 18 and cachedGraphics.bitmap.height == 18

but the Region.width is getting set to 18 and Region.tileWidth is getting set to 200

Should it be: ?

if (!Std.is(Graphic, TextureRegion))
{
region = new Region(0, 0, cachedGraphics.bitmap.width, cachedGraphics.bitmap.height);
region.width = Width;
region.height = Height;
}

(i tried the change but errors out, and I know this includes elements from flixel-ui so the issue could be before flxSprite but maybe one of you can spot an issue if there is one)

@gltovar
Copy link
Author

gltovar commented Sep 24, 2013

nevermind. wrong rabbit hole. Didn't find my fix, but this doesn't look wrong on further inspection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant