Quick Links: Download Gideros Studio | Gideros Documentation | Ultimate Guide | Gideros Development Center
Why aren't my suffixes working? - Gideros Forum

Why aren't my suffixes working?

rpallen Member
edited November 28 in General questions
I'm a bit lost with using suffixes to use different images for different sized screens.

Here is what I did. Note: Though I describe what I did here, all you really need to see is in the attached screenshot, studio.png. What I did is based on the information in the other screenshot, instructions.png, which is taken from page 23 of Arturs Sosins book, "Gideros Mobile Game Development".

The logical dimensions of the project are 960x1600 and it has landscape left orientation. In the graphics tab of the properties of my project I entered 3 suffix/ratio combinations (see screenshot):
@big 1.0
@medium 0.63
@small 0.5

I created an image for the image background.jpg and added it to the project's images folder.

I then made 3 background images from the above image and added them to the project's image folder. And yes, I added them to the images folder in the project pane after adding them to the images folder on the computer (see screenshot).
background_@big.jpg 1704x1200
background_@medium.jpg 1074x756
background_@small.jpg 852x600

I added this code to main.lua:
local bg = Bitmap.new(Texture.new("images/background.jpg", true))
bg:setAnchorPoint(0.5, 0.5)
bg:setPosition(conf.width/2, conf.height/2)
stage:addChild(bg)

When I ran the code with all FOUR images (including the background image without a suffix, in the player I got UNSUFFIXED image.

I then removed the background.jpg image, expecting the program to use the suffixed images. But I got (as you can see in the screenshot):
images/background.jpg: No such file or directory.
stack traceback:
main.lua:3: in main chunk

I assumed that something in Gideros would change background,jpg to the file with the appropriate suffix, but I guess I was wrong. What do I need to do to get the program to use the files with suffixes?
imageimage
«1

Comments

  • hgy29hgy29 Maintainer
    Hi @rpallen,

    I never used multi-scale images feature myself, but I think your images shall be just suffixed with '@xx', without the underscore. I mean background@small, not background_@small.
    +1 -1
  • olegoleg Member
    @rpallen

    gideros automatically scales
    why do you use suffixes ??
    +1 -1
  • hgy29hgy29 Maintainer
    @oleg, this is useful because low-res devicestypically support only low dimension textures as part of their OpenGL implementaion, so it is useful to provide small images that low-res devices can load and large images for hi-res devices which can typically handle much larger texture sizes.
    +1 -1
  • olegoleg Member
    edited November 28
    @hgy29
    I used a 32200x2017 image in my project
    tested on a very old smartphone 320 * 240, everything works
    but the critical size of the game file
    because the file is bigger than 20mb, the old smartphone does not load from the store ..
    and additional images increase the size of the game file
    +1 -1
  • Thanks hgy29.

    That partially corrected the problem, but "@small" still doesn't work.

    I renamed the files, removed the old files from the project and added the new ones. I then tried it out.

    I made the different image sizes basically for screen sizes of:
    big = 960x1600
    medium = 605x1008
    small=480x800

    First, I ran it with the Gideros Player settings of resolution 960x1600 and it displayed the big file. GREAT!

    Then I ran it with resolution 605x1008 and it displayed the medium file. Again, GREAT!

    But then I ran it with resolution of 480x800 and I got the error message again. So why doesn't it work with the "@small" suffix? I checked spelling several times in the file name and the suffix in the configuration and I'm pretty sure it's correct. And as you can see in the new secreenshot (studio1.png), the image is visible in the image preview pane, so it is there. Any ideas why "@small" doesn't work?
    +1 -1
  • rpallen Member
    edited November 28
    Hi oleg,
    Regarding your comment, I'm well aware of what you are saying and I'm experimenting to see if it is better to do one very large image or use suffixes.

    Why am I experimenting?

    Please see the thread from my post of November 17th, "Why not design game very large so it scales down?" That post gives both sides of the argument and didn't lead to a strong conclusion for me, so there's nothing like checking it out for myself. So that's what I'm doing.

    And if I can't successfully resolve the issue of this post, I'll certainly follow the method you recommend.
    +1 -1
  • olegoleg Member
    edited November 28
    When Gideros cannot find the alternative image to load, it loads the base image
    Also size calculations are done according to the size of the base image.


    add to the project background.jpg .

    +1 -1
  • rpallen Member
    edited November 28
    But why isn't it finding the alternate image for "small". The scale is 0.5. The logical dimensions of the project are 960x1600. The resolution of the Player is 480x800. Isn't that a scale of .5?

    When I do the resolution of the player as 605x1008, that appears to be a scale of 0.63 which is the suffix "@medium" and this does in fact display the medium image.

    So why doesn't this work for the "@small" suffix -> small image?

    I tested with adding the base image background.jpg and the error goes away and it shows the base image. But again, why doesn't this work for the "@small" suffix -> small image?
    +1 -1
  • olegoleg Member
    I think the reason is here:


    "size calculations are done according to the size of the base image."
    +1 -1
  • rpallen Member
    edited November 28
    The base image is 1704x1200.
    The small image is 852x600, which is 0.5 times the base image. But it doesn't work.
    The medium image is 1074x756, which is 0.63 times the base image and this DOES work.
    +1 -1
  • olegoleg Member
    rpallen said:

    The base image is 1704x1200.
    The small image is 852x600, which is 0.5 times the base image. But it doesn't work.
    The medium image is 1074x756, which is 0.63 times the base image and this DOES work.

    you renamed the base image from background@big.jpg in background.jpg ??

    +1 -1
  • No. I originally made background.jpg. Then I added the text "big" and saved that as the big image.
    I resized the originan image to the sizes of the other 2 images, added appropriate text and saved as the appropriate size. The text is only there so I can easily see which image is being displayed. Once it is working, the text will be removed.
    +1 -1
  • olegoleg Member
    just add a picture with the name background.jpg, without suffix
    +1 -1
  • That's what I did. See my post at 2:36 where I said, "I tested with adding the base image background.jpg and the error goes away and it shows the base image. But again, why doesn't this work for the "@small" suffix -> small image?"

    I have 4 images:
    background.jpg 1704x1200
    background@big.jpg 1704x1200 (same size as background.jpg, but different image)
    background@medium.jpg 1074x756
    background@small.jpg 852x600

    When I use the Gideros Player in 960x1600 , background@big.jpg is displayed.
    When I use the Gideros Player in 605x1008 , background@medium.jpg is displayed.
    But when I use the Gideros Player in 480x800 , background.jpg is displayed, not background@small.jpg.
    +1 -1
  • olegoleg Member
    edited November 28
    if @small put 0.49 what will output?
    +1 -1
  • OK, I just tried both 0.49 and 0.51. Both displayed the base image.

    Aye: oleg

    +1 -1 (+1 / -0 )
  • Another note:
    If I hard code the small image into the program (local bg = Bitmap.new(Texture.new("images/background.jpg", true))) the small image displays properly, so it doesn't appear there's a problem with the image file.

    If I don't have the base image file (background.jpg), the big and medium are displayed when appropriate. So it seems it is properly detecting the scale ratio. But when the Player is in a .5 ratio configuration, it gives an error message.

    When I hard code the small image, it is displayed properly. So there doesn't seem to be a problem with any of the images.

    Therefore, it seems that for some reason when it detects the .5 ration, it isn't properly associating that fact with using the @small suffix. I don't know why, nor do I know how to figure this out (troubleshoot it).
    +1 -1
  • antixantix Member
    edited November 28
    @oleg don't be fooled.. your large texture (32200x2017) will not work on a Google Nexus 4 phone. The largest texture that phone can load is 2048x2048. The Nexus 4 is quite an old phone now and it's what I use to test all of my games (and it's my actual phone also) :)

    I personally have not experimented with multiple texture sizes in projects, as my low res games all seem to look fine on whatever device they are being run on.
    +1 -1
  • olegoleg Member
    edited November 28
    antix said:

    @oleg don't be fooled.. your large texture (32200x2017) will not work on a Google Nexus 4 phone.

    "I used a 32200x2017 image" background image-not texture

    https://play.google.com/store/apps/details?id=info.simart.voyage

    testing on this phone:

    https://en.wikipedia.org/wiki/LG_Optimus_L3

    Aye: antix

    +1 -1 (+1 / -0 )
  • Thanks to all who commented. Unfortunately, though my issue hasn't been resolved, I just can't spend more time on something that I don't NEED to use and which may or may not improve my project.

    Aye: oleg

    +1 -1 (+1 / -0 )
  • pie Member
    edited November 28
    @rpallen I am not sure if that still works but I used

    suffix, scale

    @2x 2
    @4x 4


    instead of @small @medium @big
    the pictures are named accordingly
    player.png, player@2x.png, player@4x.png

    p.s. I can't remember if I set nothing on the base image or if I set nothing only as suffix and 1 as scale

    Aye: oleg

    +1 -1 (+1 / -0 )
  • Ninjadoodle Member
    edited November 28
    Like @pie, I'm using @2x and @4x and everything is working perfectly :)
    +1 -1
  • totebototebo Member
    edited November 29
    I use @2 and @3 which works fine for me. @4 peeps, is that not overkill? :)

    Not sure if it is relevant, but what scale mode are you using @rpallen? I tend to use letterbox or pixelPerfect.
    +1 -1
  • Ninjadoodle Member
    edited November 29 Accepted Answer
    Hi @totebo

    In regards to @4x - when testing my game in HTML5 on a MacBook Pro (with Retina), I can definitely tell the difference between @2x / @4x (or even @3x).

    Also, it depends what you base resolution/logical dimensions is. Mine is 320x480 which makes my @4x gfx 1280x1920 (more or less HD).

    Just out of interest, what is your base resolution/logical dimensions?

    +1 -1
  • Totebo,
    I'm using letterbox.
    +1 -1
  • rpallen Member
    edited November 29
    I have a question about resolution effect on font sizes.

    Ninjadoodle says his resolution (which I take to mean his logical dimensions) is 320x480. I assume that for this resolution, any text created with TextField will be based on a pretty small font size. How does scaling up handle this? Does it just scale up the small text size like it would scale up an image? If so, wouldn't using a device with a screen big enough to use the @4 suffix result in rather blurry text? Or does Gideros upscaling handle scaling of text differently from images?

    Edit: I just tried changing my project to logical dimensions of 324x480 and added some text using TextField. The text was an appropriate size for the screen at that resolution and it looked crisp n Gideros Player, at that screen size .

    I then viewed it again in Gideros Player with screen size 1280x1920. The text still looked crisp though the background image was NOT as crisp as at the smaller screen size. So apparently, the scaling of text is somehow different than image scaling.
    +1 -1
  • hgy29hgy29 Maintainer
    For TTFont, gideros multiplies whatever size you ask with the logical scale, to translate it in device pixels, so they should look crisp at all resolutions.

    Aye: antix

    +1 -1 (+1 / -0 )
  • Ninjadoodle Member
    edited November 29
    Hi @rpallen

    I'm not sure about TextField as I haven't really used it yet.

    I have played with Bitmap Fonts tho, and for that I use BmGlyph (Mac), which also allows you to output @2x and @4x variants.

    PS. Sorry, yup I mean 320x480 as logical dimensions.
    +1 -1
  • Well, I kinda resolved my issue, so I'm marking this as answered.

    I say, "kinda", because I still don't know why what I did doesn't work, but based on what I read here, I found something that DOES work.

    I originally used LARGE logical dimensions (960x1600) and then made my suffixes 1 or smaller because I don't expect anyone to use a resolution of bigger than 960x1600, or if they do, it won't be a lot bigger and regular scaling won't look too bad. So my suffixes were 1, 0.63 qnd 0.5. I couldn't get this to work for the 0.5 suffix.

    It seemed like everyone else was using SMALL logical dimensions, so I tried this (using the ever popular 320x480) and so the suffixes are all 1or greater, in my test case, 1, 2 and 3.17.

    This seems to be working fine, so I'll go with this. But again, I never discovered why the 0.5 suffix didn't work, which perplexes me.
    +1 -1
  • @rpallen, I use the logical dimensions of iPhone 5, and as you say scale up with @2 and @3 instead of down.
    +1 -1
Sign In or Register to comment.