Remember in Moai, you think of graphics resources in terms of Decks and Props. Decks are the actual definition of the resource – the vertex locations, texture data, etc. A Prop is a reference to a Deck and any information used to actually draw an instance of it – the actual location or any other transformation. In order for this to work though, you need to keep track of all your Decks in order to create new Props. I wrote up a class called ResourceManager to help with this.
ResourceManager = {}
--cache of filename -> deck
local cache = {}
Since we want this to be accessible anywhere, I’m treating this like a static class. That means I don’t need to use the CreateClass() function I introduced earlier – I just need to create a global scoped table and add some functions to it. Since there will only ever be one instance of this, I can create private variables by just declaring them local. Here, “ResourceManager” will be the name of the class, and we have a private table “cache”, which we will use as a dictionary with a string (filename) to Deck mapping. Continue reading ResourceManager – Keeping Track of Decks and Props→
Before getting started, I spent some time evaluating a few different middleware options. Here are some things I am looking for:
Cross-platform
I want to be able to develop and publish at the very least on PC and iOS. The Apple appstore seems relatively easy to get into, and even if it gets lost in all the other games out there, at least I can direct my friends to it and have something to show. Distribution on the PC is a little tougher since most people just buy through Steam, and you need to apply to get in. Also all my friends who are willing to help have PCs, and nobody else actually has the Macbook you need to even develop for iOS. If the code can be released on Android or Mac, that would be a nice bonus, though I’m not sure I’d want to handle the support for all the different Android devices out there. Continue reading Picking Some Middleware→