Layout module, see documentation under Display chapter
orientationChanged will no longer be called
sizeChanged will be called instead
Use the layout module to get safe area insets and size classes too
System font support
You can now use the special strings:
SYSTEM_FONT_REGULAR
Available weights:
THIN / LIGHT / ULTRALIGHT / REGULAR / MEDIUM / SEMIBOLD / BOLD / HEAVY / BLACK
In the font() function to specify use of the system font
This will allow you to use the iOS system font (San Francisco). This is different to using a fixed font file, as iOS will dynamically change between SF Display and SF Text at certain point sizes for readability. Use this font to mimic the system font appearance in your code
The exact strings and names here might change in a future beta
Fixes
Fixes crash in Froggy example when jumping on logs
The system font is “special” in that it’s really two fonts which are selected based on the current point size. This is how iOS renders text throughout its UI. So these strings let you mimic that behaviour.
I’m thinking of using exposing constants for these strings and putting them in the font picker properly. But for now you can use the strings directly.
Layout just gives you access to information about the safe area and size class.
So if you do this:
function sizeChanged(w, h)
if layout.horizontal == layout.COMPACT then
print("Using compact layout")
else
print("Using regular layout")
end
end
It should print that you’re using compact if you invoke split view and make the Codea portion of the screen small enough (depending on iPad model).
This is how most iOS apps decide when to change their layout characteristics. So I thought exposing it to Codea would be good too.
Here’s an example using OSC. Load this on both iPads and fill in the iPad address of the other iPad. Start both programs and slide your finger around the screen. The sprite on the other iPad will move.
@Simeon It seems really easy to use. I’ll have to play with it more to see if it needs changes. So far I don’t think so.
function setup()
host = osc.start() -- address of this ipad
print(host)
osc.host = "192.168.254.15" -- put address of other ipad here
x,y=0,0
end
function draw()
background(0)
sprite("Planet Cute:Character Horn Girl",x,y)
end
function osc.listen(address, ...)
arg={...}
x=arg[1]
y=arg[2]
end
function touched(t)
if t.state==MOVING then
osc.send("/",t.x,t.y)
end
end
@Simeon Something weird going on. If I have airplane mode on and run the above code on my iPad Pro, Codea crashes. On my iPad Air, it doesn’t and prints the host iPad address.
@Simeon This has probably existed in all the releases, but it probably needs fixing. If I enter something in name and press print name, I print the name in between two *. If I press clear name, the name is cleared because when I press print name, there isn’t anything between the *. But the name field isn’t cleared and I have to press backspace to clear the text area. Or is there some way to clear that area that I’m overlooking.
function setup()
parameter.text("name")
parameter.action("print name",prt)
parameter.action("clear name",clr)
end
function draw()
background(40, 40, 50)
end
function prt()
print("*"..name.."*")
end
function clr()
name=""
end
@Simeon - trivial issue but I find the error message produced above the new project name field, when there is an existing file of that name, is small and difficult to see against a dark background. A brighter colour may show up better.
Also, this may be just me, but I find sometimes when I have just edited something (usually inside brackets) like changing a value and trying to run it gives an error and the edit has disappeared. It’s happened several times but not consistently.
@Bri_G I agree about that, it’s a leftover from the very first version of Codea which didn’t even have complicated backgrounds.
I’ll try to reproduce the second issue by editing/running very fast. Perhaps the autosave hadn’t kicked in before the run command hit and it somehow used the old version.