coronate 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/README.md +24 -6
- data/bin/coronate +2 -1
- data/lib/coronate/builder/app_builder.rb +27 -0
- data/lib/coronate/builder/ebook_builder.rb +25 -0
- data/lib/coronate/builder/game_builder.rb +25 -0
- data/lib/coronate/builder/project_builder.rb +21 -0
- data/lib/coronate/builder/scene_builder.rb +13 -0
- data/lib/coronate/builder/templates/app/build.settings.tt +41 -0
- data/lib/coronate/builder/templates/app/config.lua.tt +29 -0
- data/lib/coronate/builder/templates/app/icon1-down.png +0 -0
- data/lib/coronate/builder/templates/app/icon1-down@2x.png +0 -0
- data/lib/coronate/builder/templates/app/icon1.png +0 -0
- data/lib/coronate/builder/templates/app/icon1@2x.png +0 -0
- data/lib/coronate/builder/templates/app/icon2-down.png +0 -0
- data/lib/coronate/builder/templates/app/icon2-down@2x.png +0 -0
- data/lib/coronate/builder/templates/app/icon2.png +0 -0
- data/lib/coronate/builder/templates/app/icon2@2x.png +0 -0
- data/lib/coronate/builder/templates/app/main.lua.tt +39 -0
- data/lib/coronate/builder/templates/app/view1.lua.tt +88 -0
- data/lib/coronate/builder/templates/app/view2.lua.tt +89 -0
- data/lib/coronate/builder/templates/ebook/build.settings.tt +41 -0
- data/lib/coronate/builder/templates/ebook/config.lua.tt +29 -0
- data/lib/coronate/builder/templates/ebook/coronaicon-big.png +0 -0
- data/lib/coronate/builder/templates/ebook/cover.jpg +0 -0
- data/lib/coronate/builder/templates/ebook/main.lua.tt +14 -0
- data/lib/coronate/builder/templates/ebook/moon.png +0 -0
- data/lib/coronate/builder/templates/ebook/page1.lua.tt +225 -0
- data/lib/coronate/builder/templates/ebook/pagebg1.png +0 -0
- data/lib/coronate/builder/templates/ebook/space.jpg +0 -0
- data/lib/coronate/builder/templates/ebook/sun.png +0 -0
- data/lib/coronate/builder/templates/ebook/title.lua.tt +97 -0
- data/lib/coronate/builder/templates/game/background.jpg +0 -0
- data/lib/coronate/builder/templates/game/build.settings.tt +41 -0
- data/lib/coronate/builder/templates/game/button-over.png +0 -0
- data/lib/coronate/builder/templates/game/button.png +0 -0
- data/lib/coronate/builder/templates/game/config.lua.tt +29 -0
- data/lib/coronate/builder/templates/game/crate.png +0 -0
- data/lib/coronate/builder/templates/game/grass.png +0 -0
- data/lib/coronate/builder/templates/game/level1.lua.tt +102 -0
- data/lib/coronate/builder/templates/game/logo.png +0 -0
- data/lib/coronate/builder/templates/game/main.lua.tt +14 -0
- data/lib/coronate/builder/templates/game/menu.lua.tt +115 -0
- data/lib/coronate/{templates → builder/templates/project}/build.settings.tt +0 -0
- data/lib/coronate/{templates → builder/templates/project}/config.tt +15 -0
- data/lib/coronate/{templates → builder/templates/project}/endingScene.tt +0 -0
- data/lib/coronate/{templates → builder/templates/project}/main.tt +0 -0
- data/lib/coronate/{templates → builder/templates/project}/menuScene.tt +0 -0
- data/lib/coronate/{templates → builder/templates/project}/settingsScene.tt +0 -0
- data/lib/coronate/{templates → builder/templates/project}/titleScene.tt +0 -0
- data/lib/coronate/{templates → builder/templates/project}/utils.tt +0 -0
- data/lib/coronate/builder/templates/scene/scene.tt +148 -0
- data/lib/coronate/cli.rb +56 -17
- metadata +51 -11
- data/lib/coronate/templates/scene.tt +0 -82
@@ -0,0 +1,225 @@
|
|
1
|
+
-----------------------------------------------------------------------------------------
|
2
|
+
--
|
3
|
+
-- page1.lua
|
4
|
+
--
|
5
|
+
-----------------------------------------------------------------------------------------
|
6
|
+
|
7
|
+
local storyboard = require( "storyboard" )
|
8
|
+
local scene = storyboard.newScene()
|
9
|
+
|
10
|
+
-----------------------------------------------------------------------------------------
|
11
|
+
-- BEGINNING OF YOUR IMPLEMENTATION
|
12
|
+
--
|
13
|
+
-- NOTE: Code outside of listener functions (below) will only be executed once,
|
14
|
+
-- unless storyboard.removeScene() is called.
|
15
|
+
--
|
16
|
+
-----------------------------------------------------------------------------------------
|
17
|
+
|
18
|
+
-- forward declarations and other locals
|
19
|
+
local background, pageText, continueText, pageTween, fadeTween1, fadeTween2, sunObj, moonObj, coronaIcon
|
20
|
+
|
21
|
+
local swipeThresh = 100 -- amount of pixels finger must travel to initiate page swipe
|
22
|
+
local tweenTime = 500
|
23
|
+
local animStep = 1
|
24
|
+
local readyToContinue = false
|
25
|
+
|
26
|
+
-- function to show next animation
|
27
|
+
local function showNext()
|
28
|
+
if readyToContinue then
|
29
|
+
continueText.isVisible = false
|
30
|
+
readyToContinue = false
|
31
|
+
|
32
|
+
local function repositionAndFadeIn()
|
33
|
+
pageText:setReferencePoint( display.CenterReferencePoint )
|
34
|
+
pageText.x = display.contentWidth * 0.5
|
35
|
+
pageText.y = display.contentHeight * 0.20
|
36
|
+
pageText.isVisible = true
|
37
|
+
|
38
|
+
fadeTween1 = transition.to( pageText, { time=tweenTime*0.5, alpha=1.0 } )
|
39
|
+
end
|
40
|
+
|
41
|
+
local function completeTween()
|
42
|
+
animStep = animStep + 1
|
43
|
+
if animStep > 3 then animStep = 1; end
|
44
|
+
|
45
|
+
readyToContinue = true
|
46
|
+
continueText.isVisible = true
|
47
|
+
end
|
48
|
+
|
49
|
+
if animStep == 1 then
|
50
|
+
pageText.alpha = 0
|
51
|
+
pageText.text = "High-performance, OpenGL graphics engine."
|
52
|
+
repositionAndFadeIn()
|
53
|
+
|
54
|
+
-- hide corona icon
|
55
|
+
coronaIcon.isVisible = false
|
56
|
+
|
57
|
+
sunObj.alpha = 1
|
58
|
+
sunObj.x = -sunObj.contentWidth
|
59
|
+
sunObj.isVisible = true
|
60
|
+
pageTween = transition.to( sunObj, { time=tweenTime, x=display.contentWidth*0.5, transition=easing.outExpo, onComplete=completeTween } )
|
61
|
+
|
62
|
+
elseif animStep == 2 then
|
63
|
+
pageText.alpha = 0
|
64
|
+
pageText.text = "Easy API accessed via Lua scripting."
|
65
|
+
repositionAndFadeIn()
|
66
|
+
|
67
|
+
moonObj.alpha = 1
|
68
|
+
moonObj.x = display.contentWidth + moonObj.contentWidth
|
69
|
+
moonObj.isVisible = true
|
70
|
+
pageTween = transition.to( moonObj, { time=tweenTime, x=display.contentWidth*0.5, transition=easing.outExpo, onComplete=completeTween } )
|
71
|
+
|
72
|
+
elseif animStep == 3 then
|
73
|
+
pageText.alpha = 0
|
74
|
+
pageText.text = "Corona SDK: Code Less. Play More."
|
75
|
+
repositionAndFadeIn()
|
76
|
+
|
77
|
+
-- hide sun and moon
|
78
|
+
fadeTween1 = transition.to( sunObj, { time=tweenTime*0.5, alpha=0 } )
|
79
|
+
fadeTween2 = transition.to( moonObj, { time=tweenTime*0.5, alpha=0 } )
|
80
|
+
|
81
|
+
coronaIcon.isVisible = true
|
82
|
+
coronaIcon.alpha = 0
|
83
|
+
coronaIcon.x = display.contentWidth * 0.5
|
84
|
+
pageTween = transition.to( coronaIcon, { time=tweenTime*1.5, alpha=1, transition=easing.inOutExpo, onComplete=completeTween } )
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
-- touch event listener for background object
|
90
|
+
local function onPageSwipe( self, event )
|
91
|
+
local phase = event.phase
|
92
|
+
if phase == "began" then
|
93
|
+
display.getCurrentStage():setFocus( self )
|
94
|
+
self.isFocus = true
|
95
|
+
|
96
|
+
elseif self.isFocus then
|
97
|
+
if phase == "ended" or phase == "cancelled" then
|
98
|
+
|
99
|
+
local distance = event.x - event.xStart
|
100
|
+
if distance > swipeThresh then
|
101
|
+
-- SWIPED to right; go back to title page scene
|
102
|
+
storyboard.gotoScene( "title", "slideRight", 800 )
|
103
|
+
else
|
104
|
+
-- Touch and release; initiate next animation
|
105
|
+
showNext()
|
106
|
+
end
|
107
|
+
|
108
|
+
display.getCurrentStage():setFocus( nil )
|
109
|
+
self.isFocus = nil
|
110
|
+
end
|
111
|
+
end
|
112
|
+
return true
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
-- Called when the scene's view does not exist:
|
117
|
+
function scene:createScene( event )
|
118
|
+
local group = self.view
|
119
|
+
|
120
|
+
-- create background image
|
121
|
+
background = display.newImageRect( group, "space.jpg", display.contentWidth, display.contentHeight )
|
122
|
+
background:setReferencePoint( display.TopLeftReferencePoint )
|
123
|
+
background.x, background.y = 0, 0
|
124
|
+
background.alpha = 0.5
|
125
|
+
|
126
|
+
-- create overlay
|
127
|
+
local overlay = display.newImageRect( group, "pagebg1.png", display.contentWidth, display.contentHeight )
|
128
|
+
overlay:setReferencePoint( display.TopLeftReferencePoint )
|
129
|
+
overlay.x, overlay.y = 0, 0
|
130
|
+
|
131
|
+
-- create sun, moon, and corona icon
|
132
|
+
sunObj = display.newImageRect( group, "sun.png", 300, 300 )
|
133
|
+
sunObj:setReferencePoint( display.CenterReferencePoint )
|
134
|
+
sunObj.x = display.contentWidth * 0.5
|
135
|
+
sunObj.y = display.contentHeight * 0.5
|
136
|
+
sunObj.isVisible = false
|
137
|
+
|
138
|
+
moonObj = display.newImageRect( group, "moon.png", 300, 300 )
|
139
|
+
moonObj:setReferencePoint( display.CenterReferencePoint )
|
140
|
+
moonObj.x = display.contentWidth * 0.5
|
141
|
+
moonObj.y = display.contentHeight * 0.5
|
142
|
+
moonObj.isVisible = false
|
143
|
+
|
144
|
+
coronaIcon = display.newImageRect( group, "coronaicon-big.png", 450, 444 )
|
145
|
+
coronaIcon:setReferencePoint( display.CenterReferencePoint )
|
146
|
+
coronaIcon.x = display.contentWidth * 0.5
|
147
|
+
coronaIcon.y = display.contentHeight * 0.5
|
148
|
+
coronaIcon.alpha = 0
|
149
|
+
|
150
|
+
-- create pageText
|
151
|
+
pageText = display.newText( group, "", 0, 0, native.systemFontBold, 18 )
|
152
|
+
pageText:setReferencePoint( display.CenterReferencePoint )
|
153
|
+
pageText.x = display.contentWidth * 0.5
|
154
|
+
pageText.y = display.contentHeight * 0.5
|
155
|
+
pageText.isVisible = false
|
156
|
+
|
157
|
+
-- create text at bottom of screen
|
158
|
+
continueText = display.newText( group, "[ Tap screen to continue ]", 0, 0, native.systemFont, 18 )
|
159
|
+
continueText:setReferencePoint( display.CenterReferencePoint )
|
160
|
+
continueText.x = display.contentWidth * 0.5
|
161
|
+
continueText.y = display.contentHeight - (display.contentHeight * 0.04 )
|
162
|
+
continueText.isVisible = false
|
163
|
+
end
|
164
|
+
|
165
|
+
-- Called immediately after scene has moved onscreen:
|
166
|
+
function scene:enterScene( event )
|
167
|
+
local group = self.view
|
168
|
+
|
169
|
+
animStep = 1
|
170
|
+
readyToContinue = true
|
171
|
+
showNext()
|
172
|
+
|
173
|
+
-- assign touch event to background to monitor page swiping
|
174
|
+
background.touch = onPageSwipe
|
175
|
+
background:addEventListener( "touch", background )
|
176
|
+
end
|
177
|
+
|
178
|
+
-- Called when scene is about to move offscreen:
|
179
|
+
function scene:exitScene( event )
|
180
|
+
local group = self.view
|
181
|
+
|
182
|
+
-- hide objects
|
183
|
+
sunObj.isVisible = false
|
184
|
+
moonObj.isVisible = false
|
185
|
+
coronaIcon.isVisible = false
|
186
|
+
pageText.isVisible = false
|
187
|
+
|
188
|
+
-- remove touch event listener for background
|
189
|
+
background:removeEventListener( "touch", background )
|
190
|
+
|
191
|
+
-- cancel page animations (if currently active)
|
192
|
+
if pageTween then transition.cancel( pageTween ); pageTween = nil; end
|
193
|
+
if fadeTween1 then transition.cancel( fadeTween1 ); fadeTween1 = nil; end
|
194
|
+
if fadeTween2 then transition.cancel( fadeTween2 ); fadeTween2 = nil; end
|
195
|
+
end
|
196
|
+
|
197
|
+
-- If scene's view is removed, scene:destroyScene() will be called just prior to:
|
198
|
+
function scene:destroyScene( event )
|
199
|
+
local group = self.view
|
200
|
+
|
201
|
+
-- INSERT code here (e.g. remove listeners, remove widgets, save state variables, etc.)
|
202
|
+
|
203
|
+
end
|
204
|
+
|
205
|
+
-----------------------------------------------------------------------------------------
|
206
|
+
-- END OF YOUR IMPLEMENTATION
|
207
|
+
-----------------------------------------------------------------------------------------
|
208
|
+
|
209
|
+
-- "createScene" event is dispatched if scene's view does not exist
|
210
|
+
scene:addEventListener( "createScene", scene )
|
211
|
+
|
212
|
+
-- "enterScene" event is dispatched whenever scene transition has finished
|
213
|
+
scene:addEventListener( "enterScene", scene )
|
214
|
+
|
215
|
+
-- "exitScene" event is dispatched whenever before next scene's transition begins
|
216
|
+
scene:addEventListener( "exitScene", scene )
|
217
|
+
|
218
|
+
-- "destroyScene" event is dispatched before view is unloaded, which can be
|
219
|
+
-- automatically unloaded in low memory situations, or explicitly via a call to
|
220
|
+
-- storyboard.purgeScene() or storyboard.removeScene().
|
221
|
+
scene:addEventListener( "destroyScene", scene )
|
222
|
+
|
223
|
+
-----------------------------------------------------------------------------------------
|
224
|
+
|
225
|
+
return scene
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,97 @@
|
|
1
|
+
-----------------------------------------------------------------------------------------
|
2
|
+
--
|
3
|
+
-- title.lua
|
4
|
+
--
|
5
|
+
-----------------------------------------------------------------------------------------
|
6
|
+
|
7
|
+
local storyboard = require( "storyboard" )
|
8
|
+
local scene = storyboard.newScene()
|
9
|
+
|
10
|
+
--------------------------------------------
|
11
|
+
|
12
|
+
-- forward declaration
|
13
|
+
local background
|
14
|
+
|
15
|
+
-- Touch listener function for background object
|
16
|
+
local function onBackgroundTouch( self, event )
|
17
|
+
if event.phase == "ended" or event.phase == "cancelled" then
|
18
|
+
-- go to page1.lua scene
|
19
|
+
storyboard.gotoScene( "page1", "slideLeft", 800 )
|
20
|
+
|
21
|
+
return true -- indicates successful touch
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
-----------------------------------------------------------------------------------------
|
26
|
+
-- BEGINNING OF YOUR IMPLEMENTATION
|
27
|
+
--
|
28
|
+
-- NOTE: Code outside of listener functions (below) will only be executed once,
|
29
|
+
-- unless storyboard.removeScene() is called.
|
30
|
+
--
|
31
|
+
-----------------------------------------------------------------------------------------
|
32
|
+
|
33
|
+
-- Called when the scene's view does not exist:
|
34
|
+
function scene:createScene( event )
|
35
|
+
local group = self.view
|
36
|
+
|
37
|
+
-- display a background image
|
38
|
+
background = display.newImageRect( group, "cover.jpg", display.contentWidth, display.contentHeight )
|
39
|
+
background:setReferencePoint( display.TopLeftReferencePoint )
|
40
|
+
background.x, background.y = 0, 0
|
41
|
+
|
42
|
+
-- Add more text
|
43
|
+
local pageText = display.newText( "[ Touch screen to continue ]", 0, 0, native.systemFont, 18 )
|
44
|
+
pageText:setReferencePoint( display.CenterReferencePoint )
|
45
|
+
pageText.x = display.contentWidth * 0.5
|
46
|
+
pageText.y = display.contentHeight - (display.contentHeight*0.1)
|
47
|
+
|
48
|
+
-- all display objects must be inserted into group
|
49
|
+
group:insert( background )
|
50
|
+
group:insert( pageText )
|
51
|
+
end
|
52
|
+
|
53
|
+
-- Called immediately after scene has moved onscreen:
|
54
|
+
function scene:enterScene( event )
|
55
|
+
local group = self.view
|
56
|
+
|
57
|
+
background.touch = onBackgroundTouch
|
58
|
+
background:addEventListener( "touch", background )
|
59
|
+
end
|
60
|
+
|
61
|
+
-- Called when scene is about to move offscreen:
|
62
|
+
function scene:exitScene( event )
|
63
|
+
local group = self.view
|
64
|
+
|
65
|
+
-- remove event listener from background
|
66
|
+
background:removeEventListener( "touch", background )
|
67
|
+
end
|
68
|
+
|
69
|
+
-- If scene's view is removed, scene:destroyScene() will be called just prior to:
|
70
|
+
function scene:destroyScene( event )
|
71
|
+
local group = self.view
|
72
|
+
|
73
|
+
-- INSERT code here (e.g. remove listeners, remove widgets, save state variables, etc.)
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
-----------------------------------------------------------------------------------------
|
78
|
+
-- END OF YOUR IMPLEMENTATION
|
79
|
+
-----------------------------------------------------------------------------------------
|
80
|
+
|
81
|
+
-- "createScene" event is dispatched if scene's view does not exist
|
82
|
+
scene:addEventListener( "createScene", scene )
|
83
|
+
|
84
|
+
-- "enterScene" event is dispatched whenever scene transition has finished
|
85
|
+
scene:addEventListener( "enterScene", scene )
|
86
|
+
|
87
|
+
-- "exitScene" event is dispatched whenever before next scene's transition begins
|
88
|
+
scene:addEventListener( "exitScene", scene )
|
89
|
+
|
90
|
+
-- "destroyScene" event is dispatched before view is unloaded, which can be
|
91
|
+
-- automatically unloaded in low memory situations, or explicitly via a call to
|
92
|
+
-- storyboard.purgeScene() or storyboard.removeScene().
|
93
|
+
scene:addEventListener( "destroyScene", scene )
|
94
|
+
|
95
|
+
-----------------------------------------------------------------------------------------
|
96
|
+
|
97
|
+
return scene
|
Binary file
|
@@ -0,0 +1,41 @@
|
|
1
|
+
-- Supported values for orientation:
|
2
|
+
-- portrait, portraitUpsideDown, landscapeLeft, landscapeRight
|
3
|
+
|
4
|
+
settings = {
|
5
|
+
|
6
|
+
orientation = {
|
7
|
+
default = { <%= @orient %> },
|
8
|
+
supported = { <%= @orient %> }
|
9
|
+
},
|
10
|
+
|
11
|
+
iphone = {
|
12
|
+
plist = {
|
13
|
+
UIStatusBarHidden = false,
|
14
|
+
UIPrerenderedIcon = true, -- set to false for "shine" overlay
|
15
|
+
--UIApplicationExitsOnSuspend = true, -- uncomment to quit app on suspend
|
16
|
+
|
17
|
+
--[[
|
18
|
+
-- iOS app URL schemes:
|
19
|
+
CFBundleURLTypes =
|
20
|
+
{
|
21
|
+
{
|
22
|
+
CFBundleURLSchemes =
|
23
|
+
{
|
24
|
+
"fbXXXXXXXXXXXXXX", -- example scheme for facebook
|
25
|
+
"coronasdkapp", -- example second scheme
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
--]]
|
30
|
+
}
|
31
|
+
},
|
32
|
+
|
33
|
+
--[[
|
34
|
+
-- Android permissions
|
35
|
+
|
36
|
+
androidPermissions = {
|
37
|
+
"android.permission.INTERNET",
|
38
|
+
},
|
39
|
+
|
40
|
+
]]--
|
41
|
+
}
|
Binary file
|
Binary file
|
@@ -0,0 +1,29 @@
|
|
1
|
+
application = {
|
2
|
+
content = {
|
3
|
+
width = <%= @width %>,
|
4
|
+
height = <%= @height %>,
|
5
|
+
scale = "letterBox",
|
6
|
+
fps = 30,
|
7
|
+
|
8
|
+
--[[
|
9
|
+
imageSuffix = {
|
10
|
+
["@2x"] = 2,
|
11
|
+
}
|
12
|
+
--]]
|
13
|
+
},
|
14
|
+
|
15
|
+
--[[
|
16
|
+
-- Push notifications
|
17
|
+
|
18
|
+
notification =
|
19
|
+
{
|
20
|
+
iphone =
|
21
|
+
{
|
22
|
+
types =
|
23
|
+
{
|
24
|
+
"badge", "sound", "alert", "newsstand"
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
--]]
|
29
|
+
}
|
Binary file
|
Binary file
|
@@ -0,0 +1,102 @@
|
|
1
|
+
-----------------------------------------------------------------------------------------
|
2
|
+
--
|
3
|
+
-- level1.lua
|
4
|
+
--
|
5
|
+
-----------------------------------------------------------------------------------------
|
6
|
+
|
7
|
+
local storyboard = require( "storyboard" )
|
8
|
+
local scene = storyboard.newScene()
|
9
|
+
|
10
|
+
-- include Corona's "physics" library
|
11
|
+
local physics = require "physics"
|
12
|
+
physics.start(); physics.pause()
|
13
|
+
|
14
|
+
--------------------------------------------
|
15
|
+
|
16
|
+
-- forward declarations and other locals
|
17
|
+
local screenW, screenH, halfW = display.contentWidth, display.contentHeight, display.contentWidth*0.5
|
18
|
+
|
19
|
+
-----------------------------------------------------------------------------------------
|
20
|
+
-- BEGINNING OF YOUR IMPLEMENTATION
|
21
|
+
--
|
22
|
+
-- NOTE: Code outside of listener functions (below) will only be executed once,
|
23
|
+
-- unless storyboard.removeScene() is called.
|
24
|
+
--
|
25
|
+
-----------------------------------------------------------------------------------------
|
26
|
+
|
27
|
+
-- Called when the scene's view does not exist:
|
28
|
+
function scene:createScene( event )
|
29
|
+
local group = self.view
|
30
|
+
|
31
|
+
-- create a grey rectangle as the backdrop
|
32
|
+
local background = display.newRect( 0, 0, screenW, screenH )
|
33
|
+
background:setFillColor( 128 )
|
34
|
+
|
35
|
+
-- make a crate (off-screen), position it, and rotate slightly
|
36
|
+
local crate = display.newImageRect( "crate.png", 90, 90 )
|
37
|
+
crate.x, crate.y = 160, -100
|
38
|
+
crate.rotation = 15
|
39
|
+
|
40
|
+
-- add physics to the crate
|
41
|
+
physics.addBody( crate, { density=1.0, friction=0.3, bounce=0.3 } )
|
42
|
+
|
43
|
+
-- create a grass object and add physics (with custom shape)
|
44
|
+
local grass = display.newImageRect( "grass.png", screenW, 82 )
|
45
|
+
grass:setReferencePoint( display.BottomLeftReferencePoint )
|
46
|
+
grass.x, grass.y = 0, display.contentHeight
|
47
|
+
|
48
|
+
-- define a shape that's slightly shorter than image bounds (set draw mode to "hybrid" or "debug" to see)
|
49
|
+
local grassShape = { -halfW,-34, halfW,-34, halfW,34, -halfW,34 }
|
50
|
+
physics.addBody( grass, "static", { friction=0.3, shape=grassShape } )
|
51
|
+
|
52
|
+
-- all display objects must be inserted into group
|
53
|
+
group:insert( background )
|
54
|
+
group:insert( grass)
|
55
|
+
group:insert( crate )
|
56
|
+
end
|
57
|
+
|
58
|
+
-- Called immediately after scene has moved onscreen:
|
59
|
+
function scene:enterScene( event )
|
60
|
+
local group = self.view
|
61
|
+
|
62
|
+
physics.start()
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
-- Called when scene is about to move offscreen:
|
67
|
+
function scene:exitScene( event )
|
68
|
+
local group = self.view
|
69
|
+
|
70
|
+
physics.stop()
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
-- If scene's view is removed, scene:destroyScene() will be called just prior to:
|
75
|
+
function scene:destroyScene( event )
|
76
|
+
local group = self.view
|
77
|
+
|
78
|
+
package.loaded[physics] = nil
|
79
|
+
physics = nil
|
80
|
+
end
|
81
|
+
|
82
|
+
-----------------------------------------------------------------------------------------
|
83
|
+
-- END OF YOUR IMPLEMENTATION
|
84
|
+
-----------------------------------------------------------------------------------------
|
85
|
+
|
86
|
+
-- "createScene" event is dispatched if scene's view does not exist
|
87
|
+
scene:addEventListener( "createScene", scene )
|
88
|
+
|
89
|
+
-- "enterScene" event is dispatched whenever scene transition has finished
|
90
|
+
scene:addEventListener( "enterScene", scene )
|
91
|
+
|
92
|
+
-- "exitScene" event is dispatched whenever before next scene's transition begins
|
93
|
+
scene:addEventListener( "exitScene", scene )
|
94
|
+
|
95
|
+
-- "destroyScene" event is dispatched before view is unloaded, which can be
|
96
|
+
-- automatically unloaded in low memory situations, or explicitly via a call to
|
97
|
+
-- storyboard.purgeScene() or storyboard.removeScene().
|
98
|
+
scene:addEventListener( "destroyScene", scene )
|
99
|
+
|
100
|
+
-----------------------------------------------------------------------------------------
|
101
|
+
|
102
|
+
return scene
|
Binary file
|
@@ -0,0 +1,14 @@
|
|
1
|
+
-----------------------------------------------------------------------------------------
|
2
|
+
--
|
3
|
+
-- main.lua
|
4
|
+
--
|
5
|
+
-----------------------------------------------------------------------------------------
|
6
|
+
|
7
|
+
-- hide the status bar
|
8
|
+
display.setStatusBar( display.HiddenStatusBar )
|
9
|
+
|
10
|
+
-- include the Corona "storyboard" module
|
11
|
+
local storyboard = require "storyboard"
|
12
|
+
|
13
|
+
-- load menu screen
|
14
|
+
storyboard.gotoScene( "menu" )
|
@@ -0,0 +1,115 @@
|
|
1
|
+
-----------------------------------------------------------------------------------------
|
2
|
+
--
|
3
|
+
-- menu.lua
|
4
|
+
--
|
5
|
+
-----------------------------------------------------------------------------------------
|
6
|
+
|
7
|
+
local storyboard = require( "storyboard" )
|
8
|
+
local scene = storyboard.newScene()
|
9
|
+
|
10
|
+
-- include Corona's "widget" library
|
11
|
+
local widget = require "widget"
|
12
|
+
|
13
|
+
--------------------------------------------
|
14
|
+
|
15
|
+
-- forward declarations and other locals
|
16
|
+
local playBtn
|
17
|
+
|
18
|
+
-- 'onRelease' event listener for playBtn
|
19
|
+
local function onPlayBtnRelease()
|
20
|
+
|
21
|
+
-- go to level1.lua scene
|
22
|
+
storyboard.gotoScene( "level1", "fade", 500 )
|
23
|
+
|
24
|
+
return true -- indicates successful touch
|
25
|
+
end
|
26
|
+
|
27
|
+
-----------------------------------------------------------------------------------------
|
28
|
+
-- BEGINNING OF YOUR IMPLEMENTATION
|
29
|
+
--
|
30
|
+
-- NOTE: Code outside of listener functions (below) will only be executed once,
|
31
|
+
-- unless storyboard.removeScene() is called.
|
32
|
+
--
|
33
|
+
-----------------------------------------------------------------------------------------
|
34
|
+
|
35
|
+
-- Called when the scene's view does not exist:
|
36
|
+
function scene:createScene( event )
|
37
|
+
local group = self.view
|
38
|
+
|
39
|
+
-- display a background image
|
40
|
+
local background = display.newImageRect( "background.jpg", display.contentWidth, display.contentHeight )
|
41
|
+
background:setReferencePoint( display.TopLeftReferencePoint )
|
42
|
+
background.x, background.y = 0, 0
|
43
|
+
|
44
|
+
-- create/position logo/title image on upper-half of the screen
|
45
|
+
local titleLogo = display.newImageRect( "logo.png", 264, 42 )
|
46
|
+
titleLogo:setReferencePoint( display.CenterReferencePoint )
|
47
|
+
titleLogo.x = display.contentWidth * 0.5
|
48
|
+
titleLogo.y = 100
|
49
|
+
|
50
|
+
-- create a widget button (which will loads level1.lua on release)
|
51
|
+
playBtn = widget.newButton{
|
52
|
+
label="Play Now",
|
53
|
+
labelColor = { default={255}, over={128} },
|
54
|
+
defaultFile="button.png",
|
55
|
+
overFile="button-over.png",
|
56
|
+
width=154, height=40,
|
57
|
+
onRelease = onPlayBtnRelease -- event listener function
|
58
|
+
}
|
59
|
+
playBtn:setReferencePoint( display.CenterReferencePoint )
|
60
|
+
playBtn.x = display.contentWidth*0.5
|
61
|
+
playBtn.y = display.contentHeight - 125
|
62
|
+
|
63
|
+
-- all display objects must be inserted into group
|
64
|
+
group:insert( background )
|
65
|
+
group:insert( titleLogo )
|
66
|
+
group:insert( playBtn )
|
67
|
+
end
|
68
|
+
|
69
|
+
-- Called immediately after scene has moved onscreen:
|
70
|
+
function scene:enterScene( event )
|
71
|
+
local group = self.view
|
72
|
+
|
73
|
+
-- INSERT code here (e.g. start timers, load audio, start listeners, etc.)
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
-- Called when scene is about to move offscreen:
|
78
|
+
function scene:exitScene( event )
|
79
|
+
local group = self.view
|
80
|
+
|
81
|
+
-- INSERT code here (e.g. stop timers, remove listenets, unload sounds, etc.)
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
-- If scene's view is removed, scene:destroyScene() will be called just prior to:
|
86
|
+
function scene:destroyScene( event )
|
87
|
+
local group = self.view
|
88
|
+
|
89
|
+
if playBtn then
|
90
|
+
playBtn:removeSelf() -- widgets must be manually removed
|
91
|
+
playBtn = nil
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
-----------------------------------------------------------------------------------------
|
96
|
+
-- END OF YOUR IMPLEMENTATION
|
97
|
+
-----------------------------------------------------------------------------------------
|
98
|
+
|
99
|
+
-- "createScene" event is dispatched if scene's view does not exist
|
100
|
+
scene:addEventListener( "createScene", scene )
|
101
|
+
|
102
|
+
-- "enterScene" event is dispatched whenever scene transition has finished
|
103
|
+
scene:addEventListener( "enterScene", scene )
|
104
|
+
|
105
|
+
-- "exitScene" event is dispatched whenever before next scene's transition begins
|
106
|
+
scene:addEventListener( "exitScene", scene )
|
107
|
+
|
108
|
+
-- "destroyScene" event is dispatched before view is unloaded, which can be
|
109
|
+
-- automatically unloaded in low memory situations, or explicitly via a call to
|
110
|
+
-- storyboard.purgeScene() or storyboard.removeScene().
|
111
|
+
scene:addEventListener( "destroyScene", scene )
|
112
|
+
|
113
|
+
-----------------------------------------------------------------------------------------
|
114
|
+
|
115
|
+
return scene
|
File without changes
|
@@ -12,6 +12,21 @@ application = {
|
|
12
12
|
-- How to stretch graphics on a larger screen.
|
13
13
|
scale = "letterbox"
|
14
14
|
|
15
|
+
},
|
16
|
+
|
17
|
+
--[[
|
18
|
+
-- Push notifications
|
19
|
+
|
20
|
+
notification =
|
21
|
+
{
|
22
|
+
iphone =
|
23
|
+
{
|
24
|
+
types =
|
25
|
+
{
|
26
|
+
"badge", "sound", "alert", "newsstand"
|
27
|
+
}
|
28
|
+
}
|
15
29
|
}
|
30
|
+
--]]
|
16
31
|
|
17
32
|
}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|