Codea Runtime Library

The code for saving is this:

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("spritely")

-- 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() 

function SpritelyLoader:init()
    local keys, k, s
    if readGlobalData("SpritelyKeys") == nil then
        print("No Spritely data found.")
    else
        -- read global keys
        keys = readGlobalData("SpritelyKeys")
        saveProjectData("SpritelyKeys", keys)
        print("Moving...")
        for k in string.gmatch(keys,"([^,]+)") do
            print(k)
            s = readGlobalData(k)
            saveProjectData(k, s)
        end
        print("Move complete.")
    end
    
end

What do you mean a Spritely class that’s not defined?

Also, how would I get a button to stay in the upper right corner? I have a game where you move up but I want the button to stay fixed in the top right corner. Is this possible?

Hi Bieber208,

Just a suggestion - call your routine for drawing the button last in the draw() function. Then it should overwrite whatever is there.

This is assuming you haven’t put any location parameters in the code which are updated as the app proceeds.

Hope that helps.

Bri_G

:slight_smile:

I do have location parameters that update… Is there another way to do it?

@Simeon
When i run my app the output says
“Terminating app due to uncaught exception ‘NSRangeException’, reason: ‘*** -[__NSArrayM objectAtIndex:]: index 2147483647 beyond bounds [0 … 11]’
*** First throw call stack:
(0x33e1488f 0x32906259 0x33d5d9db 0x13f47b 0x16c869 0x13e16f 0x13df53 0x35a69e53 0x35a63985 0x35a31c6b 0x35a3170f 0x35a310e3 0x332e922b 0x33de8523 0x33de84c5 0x33de7313 0x33d6a4a5 0x33d6a36d 0x35a62a13 0x35a5fe7d 0x71393 0x71338)
terminate called throwing an exception(gdb)”

And it crashes.

I’m stuck on step 3. Delete the existing the Project.codea file from the Classes group and select Move To Trash.
I hate Xcode, and can’t navigate it at all. That is why I like and use Codea. So how do I find this Project.codea file or the Classes group. There are so many views, and I have no idea where to start. Please be gentle! :slight_smile:

edit: Never mind. I just needed to click on the little triangle. No idea why that eluded me for so long!

Is there any way I can configure to use 64-bit floating point in the runtime?

Hi Bieber208,

Any chance you can post the code relevant to your button and location calculations? May help us to identify your problem.

Bri_G

B-)

@Joachim It’s a #define in one of the Lua headers. However there may be some assumed floating point use (though there shouldn’t be!) in the runtime.

Perhaps the FAQ thread should be updated - now it says that compiling App Store apps is “coming soon”.

Thanks @szleski, updated.

@Simeon, does Codea Runtime Library have support for iADs in xCode? Also, would it be possible to have in app purchases?

@Tao No they are not supported (iAD and IAP), though the source code is available, so it would be possible for someone to add support for them.

Hi everybody
I’m new in this forum (and a new Codea user). I like this IDE (and Lua) very much. I’m impressed, how smart a small game can be developed. A big thanks to the maker of this genius piece of software.

First: sorry my poor english, hope, you understand my two questions about the runtime library (-;

→ I’ve developed a small topdown shooter (codea figher :wink: ) with 4 enemy waves and a boss, in witch i’ve used some sprites of the Tyrian Remstered spritepack. In my game, the sprites will zoom with factor 2 in this way:

sprite("sprite-name", pos.x, pos.y, width * 2, height * 2)

If i run the game in codea, everything is all right, but if i compile my project with your runtime library in xcode, the sprites have the vanilla sizes. Is the zoom function not implemented yet and will this come in one of the next versions?

→ The other thing is, that the game runs very smooth inside codea with 60 fps, but the same version compiled in xcode runs with only ~30 fps. Is this ordinary?

Greetings

irus.

@irusloy it sounds like you are getting 30 fps in the iPad Simulator? That is normal. The simulator is much slower than a real iPad.

The size problem is very odd — it could be due to a retina graphics bug. Do you have a small piece of sample code that misbehaves in the runtime? I’ll look into it using the sprite line you posted above.

Edit: Also if you plan to release your game on the iOS App Store please do not use the word “Codea” in the title of your game. (You may, however, mention Codea in the description and keywords for your game. Or in the game itself.) If you do not plan to distribute your game then don’t worry about it :slight_smile:

Hi @Simeon, thank you very much for your reply. I don’t use the simulator, because i know the performance issue. I’ve used the iPad 3.
Concerning the sprite zoom, you’ve right: The iPad 2 shows the sprites correctly, the issue is only on the iPad 3.

The slow downs are on both devices; here the code samples. I use a class Enemy for draw the Enemies and a class EnemyFormation, in witch the formation will be moved (this will mean, self.position will set from the EnemyFormation class)

Enemy = class()

function Enemy:init(type)
	self.sprite = {
		"Tyrian Remastered:Enemy Ship C",
		"Tyrian Remastered:Enemy Ship D",
		"Tyrian Remastered:Enemy Ship C 1",
		"Tyrian Remastered:Enemy Ship B",
		"Tyrian Remastered:Boss A"
	}
	self.ship = self.sprite[type]
	self.position = vec2(0,0)
	....
	self.width, self.height = spriteSize(self.sprite[type])
end

function Enemy:draw() 
	
	pushStyle()
	if self.type == 1 then 
		tint(0, 196, 255, 255)
	elseif self.type == 2 then --....
	....
	end
	popStyle()

	sprite(self.ship, self.position.x, self.position.y, self.width * 2.5, self.height * 2.5)
	.....

end

If there are any typos in the code: never mind, write this post on my pc without copy/paste from the ipad :wink:

And of course, “codea fighter” is only the working title :slight_smile:

Version 1.4.1 has been pushed to the github repository.

Awesome, Dylan! Thank you!

@irusloy does that x2 problem occurs when you are recording in codea on the new iPad? I also used spritesize, same problem…