If you are migrating projects from Kwik 2 to Kwik 3 and they have external code, you will need to make some changes, otherwise your projects will not work. Also, many tutorials in our site were written to Kwik 2 and will need the same modifications to work in Kwik 3.
Why do I need to change external code?
The new scene management (Composer plus internal coding) eliminates the barrier of pages with more than 200 variables, have a much better global variable control and is faster than the previous system. However, in order to make these progresses, I had to re-write the way variables (anything in Kwik is a variable: a layer, a group, an action, etc), meaning you cannot simply call a layer by its original name in Photoshop. Lets see how it works.
Layers and group names
In Kwik 2, your layer (or group) named abc is referenced by its own name in external code. For example, if you want to change its transparency, you would write:
abc.alpha = 1
In Kwik 3, the new syntax is:
layer.abc.alpha = 1
As you can see, all layers and groups are now prefixed with “layer.” – if you forget to add this prefix, your code will not work.
Audio names
Similar to the layers case above, audios in Kwik 2, are named according their file name. For example, an audio called abc.mp3 will be named in Kwik as abc. In Kwik 3 its name become:
allAudios.abc
Like above, all audios are now prefixed with “allAudios.” – if you forget to add this prefix, your code will not work.
Page contents main group
Every page/scene in Corona holds all its graphical elements in a main group (facilitating the disposal of just one thing, instead of having to manually dispose every component of a page).
In the past Kwik used the group named menuGroup as the content owner of all elements in the page. In Kwik 3, this group is named sceneGroup, to keep compatibility with Composer API common reference.
A quick “find/replace” of menuGroup to sceneGroup will fix this issue.
Global variables
Global variables (which hold content between different pages) have a prefix _G. in Kwik 2. For example, a variable called varName, when set as global in Kwik 2 will be referenced as:
_G.varName = 1
In Kwik 3 the global variable is referenced this way:
composer.varName = 1
A quick “find/replace” of _G. to composer. will fix this issue.
Media folders
Images, audios, videos, sprite sheets, anything external called by the page code is, generally (defined in the Settings), saved in folders inside the build folder (this is the folder that holds all your final app contents). In Kwik 2 they are named as:
imgDir = “images/”
audioDir = “audio/”
videoDir = “video/”
spriteDir = “sprites/”
thumbDir = “thumbnails/”
If your image content is name p1_background.png, your page code will be similar to this:
background = display.newImageRect( imgDir.. “p1_background.png”, 1536, 2048 );
In Kwik 3, the folders above have a prefix composer.:
composer.imgDir = “images/”
composer.audioDir = “audio/”
composer.videoDir = “video/”
composer.spriteDir = “sprites/”
composer.thumbDir = “thumbnails/”
So, the background example would be written this way:
layer.background = display.newImageRect( composer.imgDir.. “p1_background.png”, 1536, 2048 );
Animations, transitions and timers
Lastly, transitions, timers and animations in Kwik 2 are prefixed differently than in Kwik 3. In Kwik 2 they are named (bold if the prefix):
transitionStash.name = transition.to…
timerStash.name = timer.performWithDelay( …
gtStash.gt_name = gtween.new…
In Kwik 3:
composer.trans.name = transition.to…
composer.timerStash.name = timer.performWithDelay( …
composer.gtStash.gt_name = gtween.new…
Again, another example of a quick “find/replace” situation.
I only set this posting as “Expert” because it requires some manual input. However, as you could see, there is not much more than a few “find/replace” situations to make the code to work with Kwik 3. For the future, all new tutorials will be written for the new Kwik.
Comments? Always appreciated!
Enjoy!