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
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.
try to reexport the texturepack using texturepacker, this helped me once.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
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.
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.
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.
@ 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.
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.
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.