Migrarting From Kwik3

Variables

  • Local Variable. For instance, you created a variable as YOUR_VARIABLE in Kwik3 and you made external codes for setting with value 1

    Kwik3

      YOUR_VARIABLE=1
    

    In Kwik4, you need to add "UI." before YOUR_VARIABLE in external code file. (You don't need 'UI." for naming a variable in creating Variable Window. Just input YOUR_VARIBLE name in text field)

    Kwik4

      UI.YOUR_VARIABLE = 1
    

As you see build4 folder, Kwik4 outputs lua files highly structured so that internally it needs UI as a name space for local variable.

  • Global variable

    Kwik3

      composer.varName = 1
    

    Kwik4

      local _K = require "Application"
      _K.YOUR_Global_VARIABLE = 1
    

Layers and group names (not changed from Kwik3)

In Kwik4, 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:

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:

Kwik3

allAudios.abc

Kwik4

UI.allAudios.abc

Assets folder

  • Kwik 3, the folders above have a prefix composer.

      composer.imgDir = “images/” 
      composer.audioDir = “audio/” 
      composer.videoDir = “video/” 
      composer.spriteDir = “sprites/” 
      composer.thumbDir = “thumbnails/”
      --
      layer.background = display.newImageRect( composer.imgDir.. “p1_background.png”, 1536, 2048 );
    
  • Kwik4 uses K for prefix and an image file is stored in p folder and the image name does not have the p prefix. For instance the correct path is _K.imgDir.. “p1/background.png

      _K.imgDir      = "assets/images/"
      _K.spriteDir   = "assets/sprites/"
      _K.thumbDir    = "assets/thumbnails/"
      _K.audioDir    = "assets/audios/"
      _K.videoDir    = "assets/videos/"
      _K.particleDir = "assets/particles/"
      --
      local _K = require "Application"    
      layer.background = display.newImageRect( _K.imgDir.. “p1/background.png”, 1536, 2048 );
    

Animations, transitions and timers

Lastly, transitions, timers and animations are prefixed

  • Kwik 3

      composer.trans.name = transition.to…
      composer.timerStash.name = timer.performWithDelay( …
      composer.gtStash.gt_name = gtween.new…
    
  • Kwik 4

      local _K = require "Application"    
      _K.trans.name = transition.to…
      _K.timerStash.name = timer.performWithDelay( …
      _K.gtStash.gt_name = gtween.new…
    

    Actions

    If you like to call the action of yours in external codes, you need to dispatch it as event

  • Kwik 3

      act_YOUR_ACTION_NAME()
    
  • Kwik4

      UI.scene:dispatchEvent({name = "action_YOUR_ACTION_NAME"})
    

Enjoy!

results matching ""

    No results matching ""