FlxButton and TextureAtlas problem

55 views
Skip to first unread message

mehmet tosun

unread,
Jul 7, 2015, 9:53:10 AM7/7/15
to haxef...@googlegroups.com
Hi,

I created a textureatlas with shoebox on Default settings.

I can get images for FlxSprite and show on screen.

But when I use FlxButton on the same way, FlxButton shows different image on screen.

My code is as follows, I working on mobile and LG G3 device.

texturepack = new SparrowData("assets/images/sprites.xml","assets/images/sprites.png");

chief = new FlxSprite();
chief.loadGraphicFromTexture(texturepack, true, "welcome_chief.png");
chief.centerOrigin();
FlxSpriteUtil.screenCenter(chief);

add(chief);

works as expected.


//Play Button
start = new FlxButton();
start.loadGraphicFromTexture(texturepack, true, "welcome_play.png");
start.x = chief.x+chief.width/2-start.width/2;
start.y = chief.y+chief.height-start.height;
start.onDown.callback = onDownClick.bind(start);
add(start);

works but do not show correct image. It gets different image from the textureatlas.

Any idea?


Thanks.

SruloArt

unread,
Jul 7, 2015, 10:12:31 AM7/7/15
to haxef...@googlegroups.com
Check the button status (FlxButton.NORMAL/HIGHLIGHT/PRESSED) and the animation frame. On mobile there's no highlight (unless you allow it). If you're trying to make a button with only the one image on all 3 statuses, then don't use FlxButton :)

mehmet tosun

unread,
Jul 8, 2015, 4:01:00 AM7/8/15
to haxef...@googlegroups.com
I change it to FlxSprite and add MouseEventManager.

Works as expected now.

Thanks.


On Tuesday, July 7, 2015 at 4:53:10 PM UTC+3, mehmet tosun wrote:

Vasco

unread,
Sep 4, 2015, 7:41:35 PM9/4/15
to HaxeFlixel
I'm having the exact same problem. When I use loadGraphicFromTexture() on a FlxButton, it always uses the same 3 frames from the texture (for "normal", "highlight" and "pressed" states), irrespective of the FrameName I use. However it works fine for FlxSprite.
Reply all
Reply to author
Forward
0 new messages