Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Problem with assets

in Bugs Posts: 237

I'm gonna start by saying @Simeon because this is a bug with Codea I believe.
Every single time I call one of my project or document assets that are being imported, it doesn't read the image. In fact, if I say readImage() for those certain images it returns nil. I know it's not a problem of syntax. I restarted my iPad and it's still not working. Anybody have a solution?

Tagged:

Comments

  • dave1707dave1707 Mod
    Posts: 7,522

    @CamelCoder What does your code look like and where is it that you're using to read your images. Maybe your trying to process the image before it has time to finish reading it. You could check if it's not nil then use it.

  • @dave1707 I tried implementing it into my game, but in didn't work. I opened a new project and imported the image into that project and when I called sprite with "Project:rocket", it was black and didn't work. Here is the asset I used. https://openclipart.org/image/2400px/svg_to_png/28806/purzen-A-cartoon-moon-rocket.png

  • dave1707dave1707 Mod
    edited February 2017 Posts: 7,522

    @CamelCoder Are you doing something like this. Change Documents:rocket to wherever you have the image. If I try using the line that's commented out instead if the one with img, it doesn't show the rocket.

    function setup()
        img=readImage("Documents:rocket")
    end
    
    function draw()
        background(0)
        sprite(img,WIDTH/2,HEIGHT/2)    -- works OK
        --sprite("Documents:rocket",WIDTH/2,HEIGHT/2)   -- doesnt show the rocket
    end
    
  • Posts: 2,020
    How many pixels is that PNG? Looks to be v high resolution. I think max texture size in Codea is 2048 pixels?
  • dave1707dave1707 Mod
    Posts: 7,522

    I copied the rocket picture to my Documents folder to use in the above code. The image size is 686x1200 or a raw size of 1372x2400. Using my code above, I have no trouble showing the Sprite.

  • @dave1707 I know that the readImage() works, except certain copies of the same image wouldn't work. I can't use readImage because I'm spawning multiple of these, which would probably cause a crash. However, @yojimbo2000 is right, I ended up getting it to work by getting a smaller size.
    Thanks for both of your help!

  • dave1707dave1707 Mod
    Posts: 7,522

    @CamelCoder I was able to create 20 different copies of the rocket image in a table and cycle thru the table to Sprite each image without Codea crashing. So at least 20 images of that size can be used.

Sign In or Register to comment.