📜 ⬆️ ⬇️

Discover Marmalade Quick, a new player in fast cross-platform development.



Good day!

Honestly, I am a little surprised why there is no mention of this in the Habré. Perhaps due to the fact that indie developers have nothing to shine ? Perhaps the reason is the exorbitant price that Marmalade asks for its product? Or are there so many alternatives that you can’t keep up with everything? As if there wasn’t, today we’ll talk about Marmalade Quick and try to show you that it fully justifies its name. I had no experience in mobile development, but Quick is so simple that in a couple of hours I managed to write a full-fledged application.
')
Why don't you try it ...

What exactly is Marmalade Quick?


Marmalade Quick allows you to write applications in the Lua language, which is now quite popular among game developers. Lua is tempting, it is very simple and powerful enough language. The ability to connect such modules as: Cocos2D-x for 2D graphics, Box2D for physics and SQLite for local data storage, JSON for data exchange.

At the moment, version 1.0 , but already implemented and added to the API:
  • Play audio and video;
  • Carrying out payment transactions in Google Play, BlackBerry World, Apple App Store;
  • Compass and positioning;
  • Facebook authorization and status update;
  • Getting general information about the device;
  • Native UI components;
  • Sockets;
  • Physics;

The core of Marmalade Quick is OpenQuick , open source and completely independent of Marmalade.
Marmalade Quick and OpenQuick are distributed under the MIT license .
You can ask questions for which you give solutions quickly enough here .
API in English is here .

Preparatory part


  1. Download and install Marmalade SDK 6.2 and higher (30 days trial version);
  2. Download Marmalade Quick . Unpack the folder with Marmalade SDK (/ quick);
  3. Run quickLaunchPad.exe in the folder / quick / tools;
  4. Import Project - import of finished projects, in particular, you can test the work of “Hello World” from the folder / quick / data / examples;
  5. New Project - create a new project;

We proceed to the development


What should we have at the end? - Bottle! Select the number of players, twist the bottle and who gets the neck, he performs the task.



Having created a new project, you create a folder with the project files. Its location can be seen in the Source Location , open its Open Folder . A folder in which all our files are / resources , and the main executable file main.lua , in which we will work.

Determine the screen resolution:
local dx=director.displayWidth local dy=director.displayHeight 

We calculate the number by which we will scale all the elements on the screen, considering that our application is designed for a screen no more than 1280x768:
 local skalex = dx/1280 local skaley = dy/768 

Let's create the first scene where the bottles are placed to select the number of players (from 4 to 10):
 local scene1 = director:createScene() --   local fon = director:createSprite( { x=0, y=0, --       source="fon.jpg", --   xScale=skalex, yScale=skaley -- ,     1280x768 } ) --     local player4 = director:createSprite( { x=dx/2-360*skalex, y=dy/2, xAnchor=0.5, yAnchor=0.5, --   ,      ; 1 -   ; 0 -    source="but/player4.png", xScale=skalex, yScale=skaley } ) local player5 = director:createSprite( { x=dx/2-240*skalex, y=dy/2, xAnchor=0.5, yAnchor=0.5, source="but/player5.png", xScale=skalex, yScale=skaley } ) local player6 = director:createSprite( { x=dx/2-120*skalex, y=dy/2, xAnchor=0.5, yAnchor=0.5, source="but/player6.png", xScale=skalex, yScale=skaley } ) local player7 = director:createSprite( { x=dx/2, y=dy/2, xAnchor=0.5, yAnchor=0.5, source="but/player7.png", xScale=skalex, yScale=skaley } ) local player8 = director:createSprite( { x=dx/2+120*skalex, y=dy/2, xAnchor=0.5, yAnchor=0.5, source="but/player8.png", xScale=skalex, yScale=skaley } ) local player9 = director:createSprite( { x=dx/2+240*skalex, y=dy/2, xAnchor=0.5, yAnchor=0.5, source="but/player9.png", xScale=skalex, yScale=skaley } ) local player10 = director:createSprite( { x=dx/2+360*skalex, y=dy/2, xAnchor=0.5, yAnchor=0.5, source="but/player10.png", xScale=skalex, yScale=skaley } ) 

So, we already have something like this:



Now let's create the second scene, the whole game takes place in it. I will not show them step by step, but rather I will write detailed comments.
 local scene2 = director:createScene() local fon = director:createSprite( { x=0, y=0, source="fon.jpg", xScale=skalex, yScale=skaley } ) --   local menu = director:createSprite( { x=dx, y=dy, xAnchor=1, yAnchor=1, source="menu.png", xScale=skalex, yScale=skaley } ) --  ""  local buty = director:createSprite( { x=dx/2, y=20, xAnchor=0.5, yAnchor=0, source="raskrutit.png", xScale=skalex, yScale=skaley } ) local neLez = nil --    local but = function() neLez = 2 tween:to(buty, { alpha=1, time=0.5, onComplete = kruti} ) --      0.5     "" (kruti). end local win_p = "WIN" -- ,     local fonz = function(event) audio:stopStream() --    r = math.random(1,42) --     1  42 s = "zadanie/"..r..".png" --   42   ,       --     local zadanie = director:createSprite( { x=dx/2, y=dy/2, --   xAnchor=0.5, yAnchor=0.5, source=s, xScale=skalex, yScale=skaley } ) --     "" local sdelano = director:createSprite( { x=dx/2, y=dy/2-180*skaley, xAnchor=0.5, yAnchor=0.5, source="sdelano.png", xScale=skalex, yScale=skaley } ) --  ,        local label = director:createLabel( { x=dx/2-90, y=dy/2+120, xAnchor=0.5, yAnchor=0.5, font="fonts/ComicSans24.fnt", --  ,   .fnt color={99, 61, 2}, --  xScale=3, yScale=3, --     3 text="Player "..win_p } ) local touchz = function(event) if event.phase == "began" then --    - began; ended -  ; moved -   ; tween:to(label, { alpha=0, time=0.5} ) --   tween:to(zadanie, { alpha=0, time=0.5} ) --   tween:to(sdelano, { alpha=0, time=0.5, onComplete = but} ) --   ""      but,      "" end end sdelano:addEventListener("touch", touchz) --   ("touch")   ""      touchz end local kruti = function(event) if event.phase == "ended" then --  if neLez == nil or neLez == 2 then local payer = math.random(1,360) -- ,    ,    1  360 win_p = math.ceil(payer/(360/players)) -- ,    ,      -- ,   local butyl = director:createSprite( { x=dx/2, y=dy/2, xAnchor=0.5, yAnchor=0.5, source=play_but, xScale=skalex, yScale=skaley } ) audio:playStreamWithLoop("mus.mp3", false) --  .mp3 ,    , false -   tween:to(buty, { alpha=0, time=0.5} ) --   "" tween:to(butyl, { rotation=payer+5400, easing=ease.expOut, easingValue=2, time=12} ) -- rotation -     ,        ,        15  (5400 ), easing=ease.expOut -    12  tween:to(butyl, { alpha=0.1, delay=14, time=1, onComplete = fonz } ) -- delay -  14 ,       0.1    fonz,        neLez = 1 end end end 




Next is the actual controls for the first scene, since we only painted the bottles, and now we’ll add them to pressing.
 local touch4 = function(event) --    4-  players = 4 --  ,     play_but = "but/4player.png" --  ,    if event.phase == "began" then --   director:moveToScene(scene2, {transitionType="crossFade", transitionTime=0.5}) --    2 end end local touch5 = function(event) players = 5 play_but = "but/5player.png" if event.phase == "began" then director:moveToScene(scene2, {transitionType="crossFade", transitionTime=0.5}) end end local touch6 = function(event) players = 6 play_but = "but/6player.png" if event.phase == "began" then director:moveToScene(scene2, {transitionType="crossFade", transitionTime=0.5}) end end local touch7 = function(event) players = 7 play_but = "but/7player.png" if event.phase == "began" then director:moveToScene(scene2, {transitionType="crossFade", transitionTime=0.5}) end end local touch8 = function(event) players = 8 play_but = "but/8player.png" if event.phase == "began" then director:moveToScene(scene2, {transitionType="crossFade", transitionTime=0.5}) end end local touch9 = function(event) players = 9 play_but = "but/9player.png" if event.phase == "began" then director:moveToScene(scene2, {transitionType="crossFade", transitionTime=0.5}) end end local touch10 = function(event) players = 10 play_but = "but/10player.png" if event.phase == "began" then director:moveToScene(scene2, {transitionType="crossFade", transitionTime=0.5}) end end local menu_back = function(event) --      if event.phase == "began" then audio:stopStream() director:moveToScene(scene1, {transitionType="crossFade", transitionTime=0.5}) --     end end player4:addEventListener("touch", touch4) --     4 player5:addEventListener("touch", touch5) --     5 player6:addEventListener("touch", touch6) --     6 player7:addEventListener("touch", touch7) --     7 player8:addEventListener("touch", touch8) --     8 player9:addEventListener("touch", touch9) --     9 player10:addEventListener("touch", touch10) --     10 buty:addEventListener("touch", kruti) --     "" menu:addEventListener("touch", menu_back) --     "" director:moveToScene(scene1) -- ,        ,              ,   ,     . 


That's all. The bottle is spinning, the music is playing ... people are performing ...

Another thing I wanted to add was that when you run the application on the device, first a black screen for a while, to speed up its disappearance, do the following:
  • Create a config.lua file
  • Add a line to it - config = {debug = {general = false}}
  • In the app.icf file, add the line to the end - configFileName = "config.lua"

Here, now everything is exactly. Keep, if suddenly someone needs, an archive with files and success in development!

Source: https://habr.com/ru/post/172249/


All Articles