Cherry is a starter for Solar2D
apps to help building your game.
- Introduction
- Usage
- Libraries
- Starters
- Components
- Music and Sounds
- License
- Third Parties
- Games using Cherry
You may extend Cherry framework, or just pick few components, in order to start your own game.
- clone Cherry next to your project
- symlink the lib to your project root:
> ln -s ../Cherry/cherry cherry
- add a
main.lua
with
-- main.lua
require 'cherry.main'
require 'src.app'
- add a
src/app.lua
- then call
App.start()
with your options
-- src/app.lua
App.start({
name = 'YourGame',
version = '1.0',
})
- add a
env/development.json
{
"silent": true,
"invincible": true,
"view-testing": "playground"
}
see env settings for more options.
A typical tree should be :
βββ Cherry
βΒ Β βββ cherry
βΒ Β βΒ Β βββ assets
βΒ Β βΒ Β βΒ Β βββ images
βΒ Β βΒ Β βΒ Β βββ sounds
βΒ Β βΒ Β βββ core
βΒ Β βΒ Β βββ components
βΒ Β βΒ Β βββ engine
βΒ Β βΒ Β βββ libs
βΒ Β βΒ Β βββ screens
βΒ Β βββ test
β
βββ YourGame
βΒ Β βββ cherry -> ../Cherry/cherry
βΒ Β βββ assets
βΒ Β βΒ Β βββ images
βΒ Β βΒ Β βββ sounds
βΒ Β β
βΒ Β βββ build.settings
βΒ Β βββ config.lua
βΒ Β βββ env
βΒ Β βββ src
βΒ Β βΒ Β βββ components
βΒ Β βΒ Β βββ extensions
βΒ Β βΒ Β βββ models
βΒ Β βΒ Β βββ screens
βΒ Β βββ test
βΒ Β βββ main.lua
from back to front:
Background
: global to the app, not reset by RouterApp.transversalBackLayer
: global to the app, not reset by Routerself.view
: local to current composer viewApp.transversalFrontLayer
: global to the app, not reset by RouterApp.hud
: local to each view, reset by Router Game.elements useApp.hud
as parent, and allow cross callbacks.
A Screen
implements the Composer library.
- Start by creating a new
screen
, for instance duplicate the simplest onesrc/screens/Playground.lua
- Register your new screen in the Router :
YOUR_NEW_SCREEN = 'YourNewScreen'
- Now you can open your screen from anywhere calling :
Router:open(Router.YOUR_NEW_SCREEN)
- Each
model
should implementnew
andshow
functions, for instance read how Item is built. - Register your model in main.lua :
YourModel = require 'game.models.YourModel'
- Use
YourModel:new()
during theLevelDrawer
parsing - Use
YourModel:show()
during theGame
rendering
Either use these components within the full workflow or pick them one by one to use it in your own game.
See documentation for the complete components list and options.
See documentation for the complete components list and options.
- screen routing
- game Camera
- touch controller
- sound library (music + effects)
- an API to register effects from CBEffects.
- user profile and game status
- google analytics events (a lot are already plugged in the workflow)
Courtesy of VelvetCoffee, you may use the samples from /assets/sounds
for your own game, providing you credit VelvetCoffee for the work and link to :
https://soundcloud.com/velvetcoffee
Luacheck, busted and luacov are used for the tests and coverage.
install the luarocks using the Makefile
, they will be created locally within .rocks/
Corona SDK embed Lua 5.1 with the apps.
To use native libs from luarocks, you must install and build them for lua 5.1, the move the .so
to an embed folder as well.
Cherry uses hererocks to locally use this version.
> pip install hererocks
> make install
> make test
now you can move your external lib to a path in your app,
and use it, after having modified your cpath
.
package.cpath = 'cherry/rocks/lib/lua/5.1/luazen.so;' .. package.cpath
local luazen = require('luazen')
UT with busted: http://olivinelabs.com/busted/
> make test
ββββββββββββ
50 successes / 0 failures / 0 errors / 0 pending : 0.014314 seconds
To display your _G.log()
use:
> make test verbose=true
To add tests to your game, use the mocks provided by Cherry:
mkdir test
cd test
ln -s ../../../Cherry/test/mocks mocks
You may use Cherry or a part of it in a free or commercial game or app, providing you follow the BSD crediting requirements, provided in the project LICENSE
- Cherry uses the awesome particle effects provided by CBEffects.
- There are some adapted functions from Underscore.Lua
- Mobile GUI assets from GraphicBurger
- Avatars from Tiny Speck
- Profile icon designed by Miguel C Balandrano
- Phantoms released on November 2015 as the actual source for
- screens : HOME required
- App.hud: empty between screens | on front
- App.display: common between screens | on back
- Look in app.App to see what you may override with
App.start(options)
- Look in engine.Game to see what you may override with
Game:YourStuff()
- env files simple example: development.json
{
"silent": true,
"view-testing": "Playground"
}
-
adding custom screens
-
extending/overriding
engine.Game
-
users from savedData:
version 3.12.6 --> 31206
- setting custom bg
- setting custom gravity
- defining colors
- defining analytics ids
- defining facebook ids
- defining ios id