spritely loader

i had problems with loading the spritely picture from the global storage. now i managed to load the spritely. but how do i draw it actually?
i thought (THOUGHT!!!) it goes like this:

function setup()
    print("Hello World!")
    loadSpritely("Lines","Bitmap","Global")
end

function draw()
    sprite("Lines",100,100)
end

but yeah, it doesnt work. how do i draw that stuff then???

More like (I think):

Function setup()
   Lines = loadSpritely("lines")
End

Function draw()
   Sprite("lines", 100, 100)
End

Ie I think it returns an image you can use. I know it doesn’t actually make a spritepack, because that would be super-cool, and is a feature many have asked for.

Same as @Bortels example, except you don’t want “lines” in quotes.

function setup()
    lines = loadSpritely("lines")
end

function draw()
    sprite( lines, 100, 100 )
end

DOH! good point, I should have caught that.

error: [string "..."]:11: bad argument #1 to 'sprite' (codeaimage expected, got nil)
Pausing playback

I’ve tried both, Same error…

copy the code here - I suspect your image load failed (and so the “lines” variable in my example is nil). make sure you have the right name, etc.

All that the loader class does is get the image from global space into project storage. You still have to load the string from project space and create the images. For example:


createImage = loadstring( readProjectData(“pencil”))

pencil = createImage()

Sprite(pencil, 100, 100)

By the way, I’m assuming that you’re using the “old” version previous to the 0.80 rewrite, in which case, here are the complete steps (from the comments in the SpritelyLoader class)

–This very simple class takes data that’s stored
– in the Sprightly global variable, and transfers
– it to project data for your project.

– For example:

– myLoader = SpritelyLoader(“bob”)

– takes the image stored from the global SpritelyGlobal
– and adds it to your project data as “bob”

– Once in the project data, load the saved string to
– an image using:

– createImage = loadstring( readProjectData(“bob”))
– anImage = createImage()

– To display your images, you’ll need to load them into
– a sprite. the command looks like this

– sprite(anImage, 100, 100, 32, 32)

– Good luck!

holy shit… look at this! i think i did something wrong :confused: here is a screenshot: http://maxiking16.posterous.com/error-d

can somebody fix my code? here it is —> http://maxiking16.posterous.com/zzz-spritely
im so sorry, i cant manage. :cry:

I would close Codea entirely and try again. Sometimes weird things happen and will continue to until you remove Codea from memory.

Tried it - no effect.

Hit [Home] to exit Codea.

Double-click [Home] to bring up the list of “running” applications.

Press on “Codea” icon at the bottom of the screen, and hold it until they all start wobbling. Touch the red ‘close’ icon in the upper-left side of the Codea icon. It (the Codea icon) should disappear.

Now, click [Home] again, and re-launch Codea. You should be better.

Hahah, i know Multitasking :wink: the Crazy picture went Off after restarting my iPad, but the error stayed. (i’ve tried restarting codea before)