resources/scenebegin.lua

Thu, 22 Aug 2013 19:50:12 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Aug 2013 19:50:12 +0200
changeset 0
bba7a2a225f6
permissions
-rw-r--r--

Flush progress with initial commit, improve application.

michael@0 1 -- Initiate scene management
michael@0 2 local sceneloc = director:createScene()
michael@0 3 sceneloc.name = 'Scene: Begin'
michael@0 4
michael@0 5 -- Calculate constants
michael@0 6 local dsw = director.displayWidth
michael@0 7 local dsh = director.displayHeight
michael@0 8 local dmw = director.displayCenterX
michael@0 9 local dmh = director.displayCenterY
michael@0 10 local nFoodpoints = 2
michael@0 11 local nAsterpoints = -2
michael@0 12 local nCometpoints = -1
michael@0 13
michael@0 14 -- Initialize common variables
michael@0 15 local spriteNull = director:createSprite(0, 0)
michael@0 16 local timerHero = director:createNode()
michael@0 17 local labReady = director:createNode()
michael@0 18 local nHealth = 0
michael@0 19 local tweenOut = 0
michael@0 20
michael@0 21 -- Instantiate common fonts
michael@0 22 local fontSegoe = director:createFont('fonts/SegoeUI-64pt_bold.fnt')
michael@0 23 local fontArial = director:createFont('fonts/Arial-96pt_bold.fnt')
michael@0 24 --local fontFxsys = director:createFont('fonts/Fixedsys-96pt_norm.fnt')
michael@0 25
michael@0 26 -- Prepare math runtime
michael@0 27 math.randomseed(os.time())
michael@0 28 math.random(); math.random(); math.random(); math.random()
michael@0 29
michael@0 30 function sceneloc:setUp(event)
michael@0 31 -- Create sprite, bottom left of image is at bottom left of display
michael@0 32 --local spriteGalaxy = director:createSprite(0, 0, 'textures/galaxyback_720.png')
michael@0 33 local spriteGalaxy = director:createSprite(0, 0, 'textures/galaxyback_360.png')
michael@0 34 spriteGalaxy.xScale = 2 -- Needed due to small maximum sprite size
michael@0 35 spriteGalaxy.yScale = 2 -- Needed due to small maximum sprite size
michael@0 36
michael@0 37 -- Animate the image to scroll along the X axis over 2 minutes
michael@0 38 funcyScroll = function(spriteIn)
michael@0 39 if spriteIn.xFlip == false then
michael@0 40 spriteIn.xFlip = true
michael@0 41 else
michael@0 42 spriteIn.xFlip = false
michael@0 43 end
michael@0 44
michael@0 45 spriteIn.x = spriteIn.x + dsh
michael@0 46 end
michael@0 47
michael@0 48 funcyGalstart = function(spriteIn)
michael@0 49 --tween:cancel(tweenReady)
michael@0 50 tweenReadweg = tween:dissolve(labReady, spriteNull, .5, 0)
michael@0 51 labReady = ''
michael@0 52 end
michael@0 53 --tween:to(spriteGalaxy, {delay=5, time=120, x=dsw-spriteGalaxy.w, mode='repeat', onComplete=funcyScroll})
michael@0 54 local tweenBack = tween:to(spriteGalaxy, {delay=5, time=100, mode='repeat', x=dsw-spriteGalaxy.w*2, onStart=funcyGalstart}) -- *2 for xyScale (above)
michael@0 55
michael@0 56 -- Instantiate star field particles behind hero
michael@0 57 local partiStarfar = director:createParticles('particles/stars.plist')
michael@0 58 partiStarfar.sourcePos = {dsw, dmh}
michael@0 59
michael@0 60 -- Create hero, middle of left edge of screen
michael@0 61 local atlasHero = director:createAtlas({
michael@0 62 width = 300,
michael@0 63 height = 200,
michael@0 64 numFrames = 8,
michael@0 65 textureName = 'textures/heroatlas.png',
michael@0 66 })
michael@0 67
michael@0 68 local animHero = director:createAnimation({
michael@0 69 start = 1,
michael@0 70 count = 8,
michael@0 71 atlas = atlasHero,
michael@0 72 delay = 1/8,
michael@0 73 })
michael@0 74
michael@0 75 local spriteHero = director:createSprite({
michael@0 76 name='hero', x=dsw/8, y=dmh,
michael@0 77 xAnchor=0.5, yAnchor=0.5,
michael@0 78 source=animHero,
michael@0 79 })
michael@0 80
michael@0 81 -- Instantiate star field particles in front of hero
michael@0 82 local partiStarnear = director:createParticles('particles/stars.plist')
michael@0 83 partiStarnear.sourcePos = {dsw, dmh}
michael@0 84
michael@0 85 -- Instantiate good things, like cheese
michael@0 86 funcyFood = function(spriteIn)
michael@0 87 --tween:cancel(tweenOut)
michael@0 88 --spriteIn.tweens[1].delay = math.random(0, 5)
michael@0 89 spriteIn.y = math.random(dsh/16, dsh-dsh/16)
michael@0 90 spriteIn.isVisible = true
michael@0 91 end
michael@0 92 local spriteCattin = director:createSprite(dsw, dmh, 'textures/cattin.png')
michael@0 93 local tweenCattin = tween:to(spriteCattin, {delay=math.random(1, 10), time=12, mode='repeat', x=-dsw, onComplete=funcyFood})
michael@0 94 spriteCattin.name = 'food'
michael@0 95 spriteCattin.xAnchor = 0
michael@0 96 spriteCattin.yAnchor = 0
michael@0 97 spriteCattin.xScale = .5
michael@0 98 spriteCattin.yScale = .5
michael@0 99 local spriteCheese = director:createSprite(dsw, dmh, 'textures/cheesepiece.png')
michael@0 100 local tweenCheese = tween:to(spriteCheese, {delay=math.random(1, 10), time=16, mode='repeat', x=-dsw, onComplete=funcyFood, xAnchor=0, yAnchor=0})
michael@0 101 spriteCheese.name = 'food'
michael@0 102 spriteCheese.xAnchor = 0
michael@0 103 spriteCheese.yAnchor = 0
michael@0 104 spriteCheese.xScale = .8
michael@0 105 spriteCheese.yScale = .8
michael@0 106 local spriteFischkopf = director:createSprite(dsw, dmh, 'textures/fischkopfe.png')
michael@0 107 local tweenFischkopf = tween:to(spriteFischkopf, {delay=math.random(1, 10), time=8, mode='repeat', x=-dsw, onComplete=funcyFood})
michael@0 108 spriteFischkopf.name = 'food'
michael@0 109 spriteFischkopf.xAnchor = 0
michael@0 110 spriteFischkopf.yAnchor = 0
michael@0 111 spriteFischkopf.xScale = .325
michael@0 112 spriteFischkopf.yScale = .325
michael@0 113
michael@0 114 -- Instantiate comets and other dangerous particles
michael@0 115 funcyStartdang = function(spriteIn)
michael@0 116 -- Adjust delay to spread out danger objects
michael@0 117 --spriteIn.
michael@0 118 end
michael@0 119 funcyComets = function(spriteIn)
michael@0 120 local locVert = math.random(dsh/16, dsh-dsh/16)
michael@0 121 spriteIn.tweens.delay = math.random(1, 10)
michael@0 122 spriteIn.y = locVert
michael@0 123 end
michael@0 124 funcyGalies = function(spriteIn)
michael@0 125 local locVert = math.random(dsh/16, dsh-dsh/16)
michael@0 126 spriteIn.tweens.delay = math.random(1, 10)
michael@0 127 spriteIn.y = locVert
michael@0 128 end
michael@0 129
michael@0 130 local posComety = math.random(dsh/16, dsh-dsh/16)
michael@0 131 local timComety = math.random(5, 12)
michael@0 132 local posGalaxy = math.random(dsh/16, dsh-dsh/16)
michael@0 133 local timGalaxy = math.random(5, 12)
michael@0 134
michael@0 135 -- Overlays needed for collision detection (particles arent detected)
michael@0 136 local spriteCom = director:createSprite({name='comet', x=dsw+dsw/4, y=posComety})
michael@0 137 spriteCom.name = 'comet'
michael@0 138 local tweenCom = tween:to(spriteCom, {delay=timComety, time=13, x=-dsw-dsw/4, mode='repeat', onStart=funcyStartdang, onComplete=funcyComets})
michael@0 139 local spriteGal = director:createSprite(dsw+dsw/4, posGalaxy)
michael@0 140 spriteGal.name = 'comet'
michael@0 141 local tweenGal = tween:to(spriteGal, {delay=timGalaxy, time=11, x=-dsw-dsw/4, mode='repeat', onStart=funcyStartdang, onComplete=funcyGalies})
michael@0 142
michael@0 143 local partiComet = director:createParticles('particles/comets.plist')
michael@0 144 --partiComet.name = 'comet'
michael@0 145 --partiComet.sourcePos = {dsw+dsw/4, posComety}
michael@0 146 --partiComet.sourcePos = {0, 60}
michael@0 147 --tween:to(partiComet, {delay=timComety, time=11, x=-dsw-dsw/4, mode='repeat', onStart=funcyStartdang, onComplete=funcyComets})
michael@0 148 local partiGalax = director:createParticles('particles/galaxies.plist')
michael@0 149 --partiGalax.name = 'comet'
michael@0 150 --partiGalax.sourcePos = {dsw+dsw/4, posGalaxy}
michael@0 151 --partiGalax.sourcePos = {0, 40}
michael@0 152 --tween:to(partiGalax, {delay=timGalaxy, time=9, x=-dsw-dsw/4, mode='repeat', onStart=funcyStartdang, onComplete=funcyGalies})
michael@0 153 spriteCom:addChild(partiComet)
michael@0 154 spriteGal:addChild(partiGalax)
michael@0 155
michael@0 156 -- Start audio streams
michael@0 157 audio:loadStream('sounds/dream.mp3')
michael@0 158 audio:playStream('sounds/dream.mp3', true)
michael@0 159
michael@0 160 -- Instantiate motor smoke particles
michael@0 161 -- Create from an initialiser list
michael@0 162 local partiSmoke = director:createParticles({
michael@0 163 totalParticles=1500,
michael@0 164 source='particles/fire.png',
michael@0 165 emitterMode=particles.modeGravity, emitterRate=1500/3.5,
michael@0 166 --sourcePos={dsw/8, dmh},
michael@0 167 sourcePos={spriteHero.w/6, spriteHero.h/2},
michael@0 168 sourcePosVar={0, 16},
michael@0 169 duration=particles.durationInfinity,
michael@0 170
michael@0 171 modeGravity={
michael@0 172 --gravity={-90, 0},
michael@0 173 speed=180, speedVar=50,
michael@0 174 radialAccel=0, radialAccelVar=0,
michael@0 175 --tangentialAccel=0, tangentialAccelVar=40,
michael@0 176 },
michael@0 177
michael@0 178 --angle=90, angleVar=20,
michael@0 179 angle=180, angleVar=10,
michael@0 180 life=4, lifeVar=2,
michael@0 181
michael@0 182 --startColor={0x80, 0x80, 0x80, 0xff}, startColorVar={0x80, 0x80, 0x80, 25},
michael@0 183 --endColor={25, 25, 25, 50}, endColorVar={25, 25, 25, 50},
michael@0 184 startColor=color.white, endColor=color.black,
michael@0 185
michael@0 186 startSize=24.0, startSizeVar=2.0,
michael@0 187 endSize=particles.startSizeEqualToEndSize
michael@0 188 })
michael@0 189 partiSmoke:stop()
michael@0 190 spriteHero:addChild(partiSmoke)
michael@0 191
michael@0 192 ---- Instantiate asteroids
michael@0 193 funcyAster = function(spriteIn)
michael@0 194 spriteIn:rotate(30)
michael@0 195 spriteIn.y = math.random(dsh/16, dsh-dsh/16)
michael@0 196 end
michael@0 197 local spriteAster1 = director:createSprite(dsw, dmh, 'textures/asteroid1.png')
michael@0 198 local tweenAster1 = tween:to(spriteAster1, {delay=math.random(5, 12), time=8, mode='repeat', x=-dsw, onComplete=funcyAster})
michael@0 199 spriteAster1.name = 'aster'
michael@0 200 spriteAster1.xAnchor = 0
michael@0 201 spriteAster1.yAnchor = 0
michael@0 202 spriteAster1.xScale = .25
michael@0 203 spriteAster1.yScale = .25
michael@0 204 local spriteAster2 = director:createSprite(dsw, dmh, 'textures/asteroid2.png')
michael@0 205 local tweenAster2 = tween:to(spriteAster2, {delay=math.random(5, 12), time=10, mode='repeat', x=-dsw, onComplete=funcyAster})
michael@0 206 spriteAster2.name = 'aster'
michael@0 207 spriteAster2.xAnchor = 0
michael@0 208 spriteAster2.yAnchor = 0
michael@0 209 spriteAster2.xScale = .25
michael@0 210 spriteAster2.yScale = .25
michael@0 211
michael@0 212 -- Instantiate explanation text
michael@0 213 labReady = director:createLabel({
michael@0 214 hAlignment='centre',
michael@0 215 vAlignment='middle',
michael@0 216 --font=fontFxsys,
michael@0 217 font=fontArial,
michael@0 218 text='Ready!',
michael@0 219 color=color.white,
michael@0 220 alpha=0})
michael@0 221 local tweenReady = tween:to(labReady, {time=.5, easing=ease.powIn, textXScale=2, textYScale=2, alpha=1})
michael@0 222
michael@0 223 -- Initialize physics simulation
michael@0 224 physics:setGravity(0, 0)
michael@0 225 local ptRndbox = {100,50, 260,50, 290,80, 290,120, 260,150, 80,150}
michael@0 226 physics:addNode(spriteHero, {isSensor = true, shape=ptRndbox})
michael@0 227 physics:addNode(spriteCattin, {isSensor = true})
michael@0 228 physics:addNode(spriteCheese, {isSensor = true})
michael@0 229 physics:addNode(spriteFischkopf, {isSensor = true})
michael@0 230 --physics:addNode(partiComet, {isSensor = true})
michael@0 231 --physics:addNode(partiGalax, {isSensor = true})
michael@0 232 local ptTri = {-45,0, 75,-90, 75,90}
michael@0 233 local ptSmal = {-30,0, 100,-20, 100,40}
michael@0 234 physics:addNode(spriteCom, {isSensor = true, shape=ptTri})
michael@0 235 physics:addNode(spriteGal, {isSensor = true, shape=ptSmal})
michael@0 236 physics:addNode(spriteAster1, {isSensor = true}) -- Set in tween instead
michael@0 237 physics:addNode(spriteAster2, {isSensor = true}) -- Set in tween instead
michael@0 238 --spriteCom.physics.radius = 50
michael@0 239 --spriteGal.physics.radius = 50
michael@0 240 -- Marmalade bug if radius is different than actual perfectly round object image
michael@0 241 spriteAster1.physics.radius = spriteAster1.w/2
michael@0 242 spriteAster2.physics.radius = spriteAster2.w/2
michael@0 243 --physics.debugDraw = true
michael@0 244
michael@0 245 -- Implement collision listener
michael@0 246 function hit(event)
michael@0 247 if event.phase == 'began' then
michael@0 248 --local labHit = director:createLabel({x=event.nodeA.x, y=event.nodeA.y, text=event.nodeB.name, font=fontSegoe, color=color.white})
michael@0 249 if event.nodeA.name == 'food' then
michael@0 250 --tween:cancel(event.nodeA.tweens[1])
michael@0 251 --tweenOut = tween:dissolve(event.nodeA, spriteNull, 1, 0)
michael@0 252 --table.insert(event.nodeA.tweens, tween:dissolve(event.nodeA, spriteNull, 1, 0))
michael@0 253 --event.nodeA.x = math.random(dsw/16, dsw-dsw/16)
michael@0 254 --event.nodeA.y = math.random(dsh/16, dsh-dsh/16)
michael@0 255 event.nodeA.isVisible = false
michael@0 256 audio:playSound('sounds/belch.pcm')
michael@0 257 nHealth = nHealth + nFoodPoints
michael@0 258 local labPoints = director:createLabel({
michael@0 259 x=0, y=0,
michael@0 260 hAlignment='centre',
michael@0 261 vAlignment='middle',
michael@0 262 textXScale=.5,
michael@0 263 textYScale=.5,
michael@0 264 --font=fontFxsys,
michael@0 265 font=fontArial,
michael@0 266 text='+' .. nFoodpoints,
michael@0 267 color=color.white,
michael@0 268 alpha=1})
michael@0 269 local tweenPoints = tween:to(labPoints, {time=1, easing=ease.powIn, textXScale=15, textYScale=15, alpha=0})
michael@0 270 elseif event.nodeB.name == 'food' then
michael@0 271 event.nodeB.isVisible = false
michael@0 272 audio:playSound('sounds/belch.pcm')
michael@0 273 nHealth = nHealth + nFoodpoints
michael@0 274 local labPoints = director:createLabel({
michael@0 275 x=0, y=0,
michael@0 276 hAlignment='centre',
michael@0 277 vAlignment='middle',
michael@0 278 textXScale=.5,
michael@0 279 textYScale=.5,
michael@0 280 --font=fontFxsys,
michael@0 281 font=fontArial,
michael@0 282 text='+' .. nFoodpoints,
michael@0 283 color=color.white,
michael@0 284 alpha=1})
michael@0 285
michael@0 286 local tweenPoints = tween:to(labPoints, {time=1, easing=ease.powIn, textXScale=15, textYScale=15, alpha=0})
michael@0 287 elseif event.nodeA.name == 'aster' then
michael@0 288 local diffiX = event.nodeB.x - event.nodeA.x
michael@0 289 local diffiY = event.nodeB.y - event.nodeA.y
michael@0 290 tween:cancel(event.nodeB.tweens[1])
michael@0 291 --tween:to(spriteHero, {time=0.5, easing=ease.powOut, easingValue=5, x=event.nodeB.x-diffiX*2, y=event.nodeB.y-diffiY*2})
michael@0 292 tween:to(spriteHero, {time=1, easing=ease.powOut, easingValue=5, x=spriteHero.x-dsw/16, y=spriteHero.y})
michael@0 293 --if device:isVibrationAvailable() then
michael@0 294 -- device:vibrate(100)
michael@0 295 --end
michael@0 296 audio:playSound('sounds/ouch.pcm')
michael@0 297 nHealth = nHealth + nAsterpoints
michael@0 298 elseif event.nodeB.name == 'aster' then
michael@0 299 tween:cancel(event.nodeA.tweens[1])
michael@0 300 tween:to(spriteHero, {time=1, easing=ease.powOut, easingValue=5, x=spriteHero.x-dsw/16, y=spriteHero.y})
michael@0 301 --if device:isVibrationAvailable() then
michael@0 302 -- device:vibrate(100)
michael@0 303 --end
michael@0 304 audio:playSound('sounds/ouch.pcm')
michael@0 305 nHealth = nHealth + nAsterpoints
michael@0 306 elseif event.nodeA.name == 'comet' then
michael@0 307 --if device:isVibrationAvailable() then
michael@0 308 -- device:vibrate(800)
michael@0 309 --end
michael@0 310 audio:playSound('sounds/torche.pcm')
michael@0 311 nHealth = nHealth + nCometpoints
michael@0 312 elseif event.nodeB.name == 'comet' then
michael@0 313 --if device:isVibrationAvailable() then
michael@0 314 -- device:vibrate(800)
michael@0 315 --end
michael@0 316 audio:playSound('sounds/torche.pcm')
michael@0 317 nHealth = nHealth + nCometpoints
michael@0 318 end
michael@0 319 end
michael@0 320 return true
michael@0 321 end
michael@0 322 spriteHero:addEventListener('collision', hit)
michael@0 323
michael@0 324 -- Implement event handlers
michael@0 325 -- General screen touch move events
michael@0 326 --Marmalade bugs cause audio to fail!
michael@0 327 function moveStart(event)
michael@0 328 --if not partiSmoke:isActive() then
michael@0 329 partiSmoke:reset()
michael@0 330 --end
michael@0 331 --local audiMotor = audio:playSound('sounds/motor.pcm') -- distracting
michael@0 332 end
michael@0 333 function moveStop(event)
michael@0 334 partiSmoke:stop()
michael@0 335 audio:stopSound(audiMotor)
michael@0 336 end
michael@0 337 function touch(event)
michael@0 338 if event.phase=='began' then
michael@0 339 --also: powIn, expIn, sineIn, elasticIn, bounceIn, backIn
michael@0 340 tween:to(spriteHero, {time=1, easing=ease.powOut, easingValue=2, x=event.x, y=event.y, onStart=moveStart, onComplete=moveStop})
michael@0 341 elseif event.phase=='ended' then
michael@0 342 -- Noop
michael@0 343 --dbg.print('Noop')
michael@0 344 --system:sendEvent('stopMotor', {timeIn=2, sizeFart=5})
michael@0 345 elseif event.phase=='moved' then
michael@0 346 tween:to(spriteHero, {time=1, easing=ease.powOut, easingValue=2, x=event.x, y=event.y, onStart=moveStart, onComplete=moveStop})
michael@0 347 end
michael@0 348 end
michael@0 349 system:addEventListener('touch', touch)
michael@0 350
michael@0 351 -- Start health timers and label appropriately
michael@0 352 nHealth = 90 -- A minute and a half of life
michael@0 353 local labHealth = director:createLabel({
michael@0 354 x=-fontArial.height*1.75, y=fontArial.height/4,
michael@0 355 hAlignment='right',
michael@0 356 vAlignment='bottom',
michael@0 357 font=fontArial,
michael@0 358 text='Health',
michael@0 359 color=color.white,
michael@0 360 alpha=.375
michael@0 361 })
michael@0 362 local labDeath = director:createLabel({
michael@0 363 x=-fontArial.height/2, y=fontArial.height/4,
michael@0 364 hAlignment='right',
michael@0 365 vAlignment='bottom',
michael@0 366 font=fontArial,
michael@0 367 text=nHealth,
michael@0 368 color=color.white,
michael@0 369 alpha=.375
michael@0 370 })
michael@0 371
michael@0 372 funcyHealth = function(event)
michael@0 373 thisNode = event.target
michael@0 374 --timerObject = event.timer
michael@0 375 --iterationsLeft = event.doneIterations
michael@0 376 --thisNode.health = thisNode.health - 1
michael@0 377 nHealth = nHealth - 1
michael@0 378 labDeath.text = nHealth
michael@0 379
michael@0 380 -- Is the game over?
michael@0 381 if nHealth <= 0 then
michael@0 382 timerHero:cancel()
michael@0 383 --audio:stopStream()
michael@0 384 --tween:cancel(tweenBack)
michael@0 385 tween:cancel(tweenCattin)
michael@0 386 tween:cancel(tweenCheese)
michael@0 387 tween:cancel(tweenFischkopf)
michael@0 388 tween:cancel(tweenCom)
michael@0 389 tween:cancel(tweenGal)
michael@0 390 tween:cancel(tweenAster1)
michael@0 391 tween:cancel(tweenAster2)
michael@0 392 system:removeEventListener('touch', touch)
michael@0 393
michael@0 394 local rectGover = director:createRectangle({
michael@0 395 x=0, y=0,
michael@0 396 w=dsw, h=dsh,
michael@0 397 strokeWidth=0,
michael@0 398 color=color.black,
michael@0 399 alpha=0})
michael@0 400 local labGover = director:createLabel({
michael@0 401 --x=0, y=fontArial.height,
michael@0 402 hAlignment='centre',
michael@0 403 vAlignment='middle',
michael@0 404 --font=fontFxsys,
michael@0 405 font=fontArial,
michael@0 406 text='GAME OVER',
michael@0 407 color=color.white,
michael@0 408 alpha=0})
michael@0 409
michael@0 410 --powIn, expIn, sineIn, elasticIn, bounceIn, backIn, easingValue
michael@0 411 local tweenGvback = tween:to(rectGover, {time=2, alpha=.6})
michael@0 412 local tweenGvtext = tween:to(labGover, {time=3, easing=ease.expIn, easingValue=3, textXScale=2, textYScale=2, alpha=1})
michael@0 413 local tweenGvlast = tween:to(labGover, {delay=3, time=1.5, mode='mirror', easing=ease.backOut, textXScale=2.125, textYScale=2.125})
michael@0 414
michael@0 415 -- Not ready for prime time (must implement back stack noch)
michael@0 416 ---- Instantiate replay and back buttons
michael@0 417 --local butPlay = director:createSprite({xAnchor=1, source='images/butplay.png', alpha=0})
michael@0 418 --butPlay.x = dmw - butPlay.w/12
michael@0 419 --butPlay.y = dmh - butPlay.h
michael@0 420 --local butBack = director:createSprite({source='images/butback2.png', alpha=0})
michael@0 421 --butBack.x = dmw + butBack.w/12
michael@0 422 --butBack.y = dmh - butBack.h
michael@0 423 --tweenButplayin = tween:to(butPlay, {delay=4.0, time=1, alpha=1})
michael@0 424 --tweenButbackin = tween:to(butBack, {delay=4.5, time=1, alpha=1})
michael@0 425 --function butPlay:touch(event)
michael@0 426 -- if event.phase == 'began' then
michael@0 427 -- director:moveToScene(sceneBegin, transoptr)
michael@0 428 -- end
michael@0 429 -- return true
michael@0 430 --end
michael@0 431 --butPlay:addEventListener('touch', butPlay)
michael@0 432 --function butBack:touch(event)
michael@0 433 -- if event.phase == 'began' then
michael@0 434 -- director:moveToScene(sceneIntro, transoptr)
michael@0 435 -- end
michael@0 436 -- return true
michael@0 437 --end
michael@0 438 --butBack:addEventListener('touch', butBack)
michael@0 439 end
michael@0 440 end
michael@0 441 --timerHealth = system:addTimer(funcyHealth, 1, 0, 4)
michael@0 442 timerHero = spriteHero:addTimer(funcyHealth, 1, 0, 4)
michael@0 443 end
michael@0 444
michael@0 445 function sceneloc:tearDown(event)
michael@0 446 dbg.print('sceneloc:tearDown')
michael@0 447 audio:stopStream()
michael@0 448 --self.releaseResources()
michael@0 449 --self.<obj-here> = self.<obj-here>:removeFromParent()
michael@0 450 --self.obj0:removeFromParent()
michael@0 451 --self.obj1:removeFromParent()
michael@0 452 --self.obj0 = nil
michael@0 453 --self.obj1 = nil
michael@0 454 end
michael@0 455 function sceneloc:enterPreTransition(event)
michael@0 456 dbg.print('sceneloc:enterPreTransition')
michael@0 457 end
michael@0 458 function sceneloc:enterPostTransition(event)
michael@0 459 dbg.print('sceneloc:enterPostTransition')
michael@0 460 end
michael@0 461 function sceneloc:exitPreTransition(event)
michael@0 462 dbg.print('sceneloc:exitPreTransition')
michael@0 463 end
michael@0 464 function sceneloc:exitPostTransition(event)
michael@0 465 dbg.print('sceneloc:exitPostTransition')
michael@0 466 end
michael@0 467
michael@0 468 sceneloc:addEventListener({'setUp', 'tearDown', 'enterPreTransition',
michael@0 469 'enterPostTransition', 'exitPreTransition', 'exitPostTransition'}, sceneloc)
michael@0 470
michael@0 471 return sceneloc
michael@0 472

mercurial