-
Notifications
You must be signed in to change notification settings - Fork 63
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
extending a flxuibutton and using the 9scaling #19
Comments
resize() is what you should be using. Adjusting width and height directly will not cause the 9slice asset to resize itself correctly. What errors are you getting? And can you post a gist? |
at the moment the build looks broken from the latest commits . there is an issue on flixel side, but there might be some flixel ui things too: when the build is fixed I can get into is some more =] I wanted to see if the latest changes fixed it |
I'm in the process of getting a pull request accepted to flixel: Maybe switch to my flixel fork's dev branch temporarily until it goes through? I've just updated flixel-ui's dev branch with my latest stuff. |
sure i'll do that one, one sec. |
https://gist.github.com/gltovar/6705447 this is causing an error on FlxSprite line 618 the frame (FlxFrame) object is null. If I add a few null checks up the line, then the item is rendered improperly (not resized at all) Im going to double check this now, just to make sure the latest updates didn't fix it. |
Interesting. Let me know if it's still broken in latest updates, then I'll try to repro. |
I assume this is flash target? or CPP? |
flash at the moment, haven't tried a cpp target yet |
what's your "button" definition, if I may ask? Is it custom or are you using an included definition? |
oh, but even before using the xml, I was just manually doing a: this.loadGraphicSlice9( ["assets/gfx/ui/buttons/button_blue.png"], 18, 18, ["6,6,11,11"] ); on a button and it also causes the error. here is a gist of the xml i am using: https://gist.github.com/gltovar/6705563 its a near copy of one of the examples in the RPG interface. |
okay thanks. And confirmed the latest updates don't fix it? |
doesn't look like it. |
if I do a null check for frame on line 618 on flxsprite this is what it renders out http://screencast.com/t/llc2l4An9ah7 |
Thanks for bearing with me. I'm trying to repro now. |
Okay, think I've repro'd. Let's narrow this thing down. |
i was thinking this part of flxSprite::LoadGraphic() might be the issue: if (!Std.is(Graphic, TextureRegion)) because in the future updateFrameData() might have the wrong parameters for the region
but i don't pin down what is going wrong there |
good thoughts, might be related to the recent refactoring in flixel animation system! |
what's strange is the RPG Interface in flixel-demos still seems to compile just fine. Does that work for you? |
it compiles, but breaks when i click on save or battle. but at the moment I'm trying to make sure I have the latest flixel-demos in my libs... its taking its sweet time What im looking for in the demos is for a button that isn't the default width/height of 80 by 20 |
ok with the latest demo code i can see the rpg interface working again. I'll look at the button code to see if I can see differences |
I might have started to find your error but I'll have to finish investigating tomorrow. Let me know what you find. |
so in toying around i found that if i change the save menu's button size (big_button_blue) in the xml. Looks like when the bounds (at least hight wise) gets bigger or equal than the original image size (54px in this case) the error gets hit. So the slightly larger buttons in the save menu are just being scaled to 34px but if you change it to 54 or bigger then its breaks (53 works) So i think there is some merit to the region, and where ever the size of a sprite is kept being an issue but haven't quite find the root cause just yet. |
I noticed that line 288 of FlxUITyped Button has this: but i think it should see if src_h should be taken into account if its set, right? (going to try it, but not sure if i'm interpreting src_w and src_h correctly |
nice i think that was the problem: on line 288 i changed it to: |
ok so now setting the buttons size in the xml is fixed i just tried doing it manually though code: http://screencast.com/t/2Zw9EY7MoWt and here is the result So im going to hunt down why it isn't setting the proper height (it should take up the whole bottom right corner. looks like its defaulting to the standard button height. |
Thanks so much for looking into this for me, I've been kind of busy the On Thu, Sep 26, 2013 at 6:24 PM, gltovar notifications@github.com wrote:
www.fortressofdoors.com -- Games, Art, Design |
Open source collaboration for the win! Great work gltovar. |
Okay, so line 288 looks like I might have a logic error. What it's supposed to do is look at the asset and determine whether it looks like a stacked asset with multiple frames, or is just one frame. To do that, it checks if the object's height (all.height) is greater than the target button frame height (H). However, this fails to account for the fact that we're 9-slice-scaling, which means the source asset is probably going to be pretty dang small. So if the standard source rectangle is, say, 10x10, and I want a button that's 300x300, 30 < 300 and the algorithm will guess wrong. Checking vs. the source width and height should work correctly, however. So.... I might have to just stop trying to be smart here, and demand that the user supply metadata if they're using a 9-slice asset. |
I think I can have my cake and eat it too! So, from now on, if you only have one asset provided, it throws an error if src_w and src_h aren't defined as that's an ambiguous situation. HOWEVER, during the loading phase, Flixel-UI does have enough information to know what to do. It knows when you're using an "all" asset, so it can calculate the proper src_w and src_h at that time and pass it along, if the user hasn't supplied his/her own values. |
Working on some patches. Hopefully this will fix some things. |
Okay, think I've fixed it. RPG Interface is working again, and I've fixed the offending line of code. Hopefully this fixes your issues (and artifacts) without causing new problems.... Please confirm whether this is fixed for you and I'll close this issue. |
sure thing i'll check it out shortly. thanks =] |
It is looking good =] thanks so much the last part of the issue i was having was using the method incorrecly because of a glitch in the code hinting in sublime text: http://www.sublimetext.com/forum/viewtopic.php?f=3&t=14227 it was masking some of the actually parameters because it was thinking the commas in the string literal for the slicing were satisfying other parameters leading to this: instead of this: and one of the 18's was being used for tile mode or maybe ratio. (i think) I am glad to have helped fix this issue, and thanks again so much for the help! |
Cool, let's close this! |
i was having an issue that I outlined here:
HaxeFlixel/flixel#650
but maybe this is way simpler than i am thinking:
I have an button that extends FlxUIButton
and in the constructor I call super, then I call load loadGraphicSlice9 and in ( ["assets/gfx/ui/buttons/button_blue.png"], 18, 18, ["6,6,11,11"] );
this works and you can see a 18 by 18 button in the application..
I just trying to figure out the proper way to adjust the size of the button using the 9 slicing. I've tried resize() (erros) changing width and height ad different times (pre and post constructor) and different values in the loadGraphicSlice9 spot.
thanks in advance for the advice/help
The text was updated successfully, but these errors were encountered: