Publising From Codea Advice

Hello Codea’ers, I’m looking for some advice. Once you have project exectly how you want in Codea, how much work is there left to publish it? I’m someone who has never worked with xCode and doesnt have an apple developer account or a mac so in your opinion, how big of a risk is it to purchase a mac for this purpose?

Have to purchase a $99 per year developer account, then create provisioning profile and stuff for the app (videos on youtube for this) in iTunes connect. Once that is done its pretty simple from the Xcode standpoint. Just export the project to dropbox, open it on a mac (or Hackintosh using virtualbox) in Xcode, then a few changes in Xcode like setting the app icons (all icons are made by Codea when exporting) for the various devices if universal, and making sure the bundle identifier and stuff is correct, then submit to apple.

I was going to buy a Mac Mini off of craigslist for $250 or so to have a Mac for submitting apps, but managed to get my PC to run Niresh Hackintosh through virtualbox. Its kind of a pain though, easier to get a real mac if you have the spare cash.

@Crumble Thanks for the info. Do you know how much trouble it is to go universal?

@Goatboy76 I’ve done a couple of universal apps. I tested them in Codea by subbing different values for height and width. They worked fine.

The whole process of getting from Codea to App Store can best be defined as tedious, between provisioning profile, distribution id, bundle id, and all the other minutiae, it’s easy to get lost. Just take it slow. A checklist helps.


For universal apps, just make every constant value a number relative to HEIGHT or WIDTH. For example, if a sprite is placed at the coordinates x=384, y=256 in portrait mode, you would instead do x = WIDTH/2 (which is 768/384), y = HEIGHT/4 (which is 1024/256). Do that with every constant value, including fontSize and the speed of moving objects.

With the way iDevices have different aspect ratios, its best to do the coordinates as above, but for the size of objects, do both dimensions relative to the WIDTH in portrait or HEIGHT in landscape, so a sprite that is a size of x=128 and y=256 in portrait mode, you would make it x=WIDTH/6 and y = WIDTH/3. This gets around the objects being stretched in strange ways on different devices and messing with the gameplay.

Check out this thread that I made which has a 100 line game example that is first non-universal, then converted to universal.

@Crumble - good advice thanks for sharing

@Crumble Wouldent it be easier to make a constant thats a multiplyer for each axis to adjust values? Like

xPos = 250 * X_MULTI

The current width divided by the native that it was made on.

I often find that I want to try different arrangements and layouts on different devices, so I don simply scale everything. Instead, I start off by setting two variables: height and width. I then treat these variables as if they were the boundaries of the screen. I can set these lower case variable names equal to any value to test how things look on various iPhone models. Then before going to XCode I set width = WIDTH and height = HEIGHT.


Yeah, there is probably an easier way of doing it, I’m still kind of a newbie to programming, so I just use the first solution that I found that works. I like the idea of creating a multiple in setup.

So let me see, if you had an iPhone 4 with WIDTH of 480 in landscape, X_MULI = WIDTH/1024= 480/1024 = .46875 , so for the a center position when developing on iPad it would be xPos = 512 * X_MULTI = 512 * .46875 = 254.0625. Not quite in the center. I think you are on the right track, but that doesn’t seem to be the solution. Unless my math is wrong.

Edit: I think what you would want to do for the multiple is X_MULTI = 1024/WIDTH and xPos = iPad position value/X_MULTI which would give the correct position for any screen dimension. For example on iPhone 4 with a WIDTH of 480 in landscape, if you want a sprite positioned in the center on the X axis, X_MULTI = 1024/WIDTH = 1024/480 = 2.133333333 and xPos = iPad position value/X_MULTI = 512/2.13333333 = 240. Seems to work.

So you just create the X_MULTI = 1024/WIDTH and Y_MULTI = 768/HEIGHT variable in setup if working in landscape mode, then when developing on iPad just add /X_MULTI after any constant x value, or /Y_MULTI after any y value, and it’s universal. Genius! Saves me a lot of calculator time.

Very good idea Goatboy76, I think I’m going to start doing that.

Personally for universal builds I tend to express all my coordinates in terms of 0 - 1 so to position a sprite a quarter of the way across the screen I use an x value of 0.25 and then scale everything by WIDTH or HEIGHT.

I tend to use a function like this

function COORD(x,y)
   if x <= 1 then x = x * WIDTH end
   if y <= 1 then y = y * HEIGHT end
   return x,y

That way I can pass either values in the range of 0-1 or “normal” values and they both work.

But I also agree with @Goatboy76 - use local constants where ever possible rather than recalculating all the values that don’t change every frame.

@Crumble I thought that you didn’t have to do fontSize, because it’s in points, not pixels?

Again the way I work this is to use a fontSizeEm() function where I scale the size of the font by an initially defined scale factor.

In my terminology, oneEm is the scaled width of an uppercase M character, so that regardless of the actual value of WIDTH you can print characters that will take up the same percentage of the screen.

For example if I print “MMMMMMMMMM” at a given “em” size and it fills the screen, then it’ll fill the screen regardless of what I set WIDTH to (if that makes sense - maybe a code example will help :slight_smile: )

oneEm = WIDTH / 320

function fontSizeEm(s) fontSize(s * oneEm) end

The 320 is chosen as it gives a scale factor of 1 on iPod / iPhone3GS which is the smallest width and ensures that I only ever scale up.

The problem with my way is how do you do dependencies?

@SkyTheCoder Is there a way to test that in Codea?

@Goatboy76 Nope.

@Goatboy76 - what do you mean by dependencies?
I have a function called FAKE_DEVICE() which I pass in a table of the desired width, height etc - I call this from inside my main setup() function and as I set WIDTH & HEIGHT they are accessible from all my dependant tabs.

Granted any code outside of a function to setup constants etc based off WIDTH & HEIGHT wouldn’t work - but to get round that I just have an initialisation function that get’s called from setup() after I’ve called FAKE_DEVICE()

@TechDojo The dependenices are other project thats you can pull from. I guess that you just have to set all of the dependencies sizes as parameters when there made instead of having them decide how big they are.

I just use WIDTH & HEIGHT, although my dependencies tend to be more library code than application code. If you’re defining any globals then the initialisation should be moved to a function.