Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Newbie Question: Texture sheet images wont load. - Gideros Forum

Newbie Question: Texture sheet images wont load.

RedpicmanRedpicman Member
edited October 2015 in Bugs and issues
Hi everyone,

I have just started to learm gideros, and while I am able to load images as a single file, I run into difficluties when I try to load a region of a sprite sheet as a bitmap. Please can some one give me any ideas what I am doing wrong. When I run the code, it does not throw an error but the picture does not display either. Just to check that it is something that i am not doing wrong I used the sprite sheet from the gideros book, but still no joy. Here is the code below and I am using the scene manager also.

Level1 = Core.class(Sprite)

function Level1:init()
local pack = TexturePack.new("texturepack/levelScene.txt", "texturepack/levelScene.png",true)
local face = Bitmap.new(pack:getTextureRegion( "restart.png"))
face:setPosition(application:getContentWidth()/2 ,application:getContentHeight()/2)
self:addChild(face)
end

I have also tried making pack a property of level1 (like they do in the book) but I still cant get it to work. I know the answer is going to be something really simple, but for the life of me I can not see it.

Comments

  • The code looks good. Have you remembered to add the Sprite instance of "Level1" to the stage?
    My Gideros games: www.totebo.com
  • Hi, totobo,

    do you mean:

    sceneManager = SceneManager.new({
    ["title"] = TitleScreen,
    ["level1"] = Level1,
    })

    if so the answer is yes. I can load normal images into this level and they will display. But for some reason I can display the image when it is part of a texture sheet. Its driving me nuts at the moment. At first I thought it might have had something to do with the sprites I had put on the sheet ( one of them was quite big) so I decided to swap it for one sheet that had worked in the gideros book. but it still does not work.

    Any other ideas ? I am a newbie to this but I have used corona in the past, but I really like the way gideros is implemented, and the fact that I dont have to beam my file of somewhere to get an apk is a massive draw.
  • maybe your texturepack txt or png is corrupted in some way and restart.png refers to some area of the levelscene.png where nothing is in fact.
    try to reexport the texturepack using texturepacker, this helped me once.
  • To test just the texturepack this code should be enough.
    local pack = TexturePack.new("texturepack/levelScene.txt", "texturepack/levelScene.png",true)
    local face = Bitmap.new(pack:getTextureRegion( "restart.png"))
    stage:addChild(face)
    Try that and report back!
    My Gideros games: www.totebo.com
  • hi totebo,

    No I replaced my code with the one you posted still no joy. I also moved the code into the main file and tried it, still no success. Although, keszegh reminded when I was using corona and copyed and pasted files in windows 8 they never seemed to work. It was almost like windows 8 was adding something extra to the file. In the end I had to open the file up in notepad and resave the file in the notepad++ program. I am using windows 10 (don't laugh) at the moment. The only other thing that is different between my version ( which does not work) and the book's version that does is that I am using the latest screen manager. But I think I have ruled that out by running the code in the main file.

    interesting, I will have to investigate further tomorrow.

  • Yeah, very strange! Let us know if you figure it out.
    My Gideros games: www.totebo.com
  • yes i think i know the problem.

    my problem was following.

    i created an texture sheet with 1-1.png 1-2.png etc...

    i got an error from the code. i used the mac version.

    so i looked into in the tilessheet.txt and there was no 1-1.png they started with 1-2.png
    i solved this problem i created an 0-1.png before 1-1.png and boom no 0-1.png but the 1-1.png was there.

    it seems that the texture packer cut off the first position.

    hope this should solved your problem.
  • piepie Member
    @Redpicman just to understand if the bug is on windows10 or somewhere else:
    upload a zip with your images (or dummy images with this same behaviour) I will pack them for you on win7

    @GiderosFan I tried with 6 images labeled as yours on win7 gideros texture packer and I have them all as expected.
    Do the same thing as Redpicman, I will pack them on my laptop and let's see if it works.

    I can't fix things on core, but at least we could try narrowing the issue for someone with the right skills. :)
  • Funny thing is today I tried some other sprites on someone else's laptop (which was also win 10) and hey presto they work. So It must be something I did wrong in creating the texture sheet. Are there any rules on creation on these sheets. I know when you created textures for unreal 3 engine they had to be a) square (which I know the gideros texture packer does) and b) it has to be a base 2 size I.e. 32 x 32, 64 x 64, 128 x128 ..... Etc.

    @ pie will try again tomorrow with my computer. If still don't work, then I will take you up on your offer if you don't mind.
  • piepie Member
    @Redpicman no problem at all, I am interested in spotting this bug (if it is a bug) since windows 10 is going to be the next windows standard :)

    As far as I know there is no "requirement" about power of 2 textures in gideros, but it helps in some way. If you flag "Force Square" in texture packer should be enough though.
  • Hi everybody,
    Had some time to test, and while I am not completely sure why, but I took the images that I got working on the windows 10 laptop and tried them on my desktop. And once again they did not work. After going over what was different between the laptop and the desktop, I did notice that windows firewall was blocking the private setting. Anyway to cut a long story short, I made sure that both public and private settings were ticked in the firewall, both for gideros player and studio. The bad news is that while this solves the problem for files created after you do this change, it did not seem to work for files already started. So you might have to copy and paste your code into a new project.

    But after I did this I could now get the texture sheet region to display, from the sheet that was working on the laptop.

    I hope this saves someone the hours I have spent working it out. If someone with some windows knowledge has the reason why I would love to know it.
Sign In or Register to comment.