local PARALLAX_DURATION = 10.0
local FADE_IN_DURATION = 1.0

function runGymCutscene(cutscene)
    local wall = CCSprite:create("Images/UI/Gym/background.png")
    wall:setAnchorPoint(ccp(0.5, 0.0))
    wall:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(10.0, 82.5)))
    wall:setScale(0.5)
    cutscene:addChild(wall)

    local map = CCSprite:create("Images/UI/Cutscenes/panel_map.png")
    map:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-73.0, 183.0)))
    map:setScale(0.5)
    cutscene:addChild(map)

    local woodFloor = CCSprite:create("Images/UI/Cutscenes/panel_woodfloor.png")
    woodFloor:setAnchorPoint(ccp(0.5, 1.0))
    woodFloor:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(12.0, 120.5)))
    woodFloor:setScale(0.5)
    cutscene:addChild(woodFloor)

    local coach = CCSprite:create("Images/UI/Cutscenes/panel_coach_front.png")
    coach:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-126.5, 153.0)))
    coach:setScale(0.5)
    cutscene:addChild(coach)

    local brooke = CCSprite:create("Images/UI/Cutscenes/panel_brooke_back.png")
    brooke:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(199.5, 141.0)))
    brooke:setScale(0.5)
    cutscene:addChild(brooke)

    local brick = CCSprite:create("Images/UI/Cutscenes/panel_brick_back.png")
    brick:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(98.5, 138.5)))
    brick:setScale(0.5)
    cutscene:addChild(brick)

    local brickFace = CCSprite:create("Images/UI/Cutscenes/panel_brick_portrait.png")
    brickFace:setOpacity(0)
    brickFace:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_RIGHT), ccp(-203.0, 212.5)))
    brickFace:setScale(0.25)
    cutscene:addChild(brickFace)

    local brookeFace = CCSprite:create("Images/UI/Cutscenes/panel_brooke_portrait.png")
    brookeFace:setOpacity(0)
    brookeFace:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_RIGHT), ccp(-91.5, 138.5)))
    brookeFace:setScale(0.25)
    cutscene:addChild(brookeFace)

    coroutine.yield()

    wall:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(0.0, 82.5))))
    map:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-83.0, 183.0))))
    woodFloor:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(0.0, 120.5))))
    coach:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-138.5, 153.0))))
    brooke:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(176.5, 141.0))))
    brick:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(69.5, 138.5))))

    AudioManager:postEvent("Cutscene_Gym")
    AudioManager:postEvent("Cutscene_Coach")
    cutscene:setSpeaker("Coach")
    cutscene:setText(cutscene:getKey() .. "Coach")

    coroutine.yield()

    local popUpAction1 = CCSpawn:createWithTwoActions(CCFadeTo:create(0.1, 255), CCEaseElasticOut:create(CCScaleTo:create(0.4, 0.5), 0.3))

    brickFace:runAction(popUpAction1)

    AudioManager:postEvent("Cutscene_Brick")
    cutscene:setSpeaker("Brick")
    cutscene:setText(cutscene:getKey() .. "Brick")

    coroutine.yield()

    local popUpAction2 = CCSpawn:createWithTwoActions(CCFadeTo:create(0.1, 255), CCEaseElasticOut:create(CCScaleTo:create(0.4, 0.5), 0.3))

    brookeFace:runAction(popUpAction2)

    AudioManager:postEvent("Cutscene_Brooke")
    cutscene:setSpeaker("Brooke")
    cutscene:setText(cutscene:getKey() .. "Brooke")

    coroutine.yield()

    AudioManager:postEvent("Cutscene_Done")

    -- Cleanup code here
end

function runIntroCutscene(cutscene)
    local HORIZON_HEIGHT = 115.5
    local ANTI_TILING_ARTIFACT_OFFSET = 0.5

    local sky = ScrollingSprite:create("Images/UI/MainMenu/BG_sky.png")
    sky:setAnchorPoint(ccp(0.0, 0.0))
    sky:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_LEFT), ccp(0.0, HORIZON_HEIGHT - ANTI_TILING_ARTIFACT_OFFSET)))
    sky:setScale(0.5)
    sky:setTileX(2.3)

    local water = ScrollingSprite:create("Images/UI/MainMenu/BG_water.png")
    water:setAnchorPoint(ccp(0.0, 1.0))
    water:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_LEFT), ccp(0.0, HORIZON_HEIGHT + ANTI_TILING_ARTIFACT_OFFSET)))
    water:setScale(0.5)
    water:setTileX(2.3)

    local cityPosition = ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_LEFT), ccp(0.0, HORIZON_HEIGHT - ANTI_TILING_ARTIFACT_OFFSET))

    local city3 = ScrollingSprite:create("Images/UI/MainMenu/BG_city03.png")
    city3:setAnchorPoint(ccp(0.0, 0.0))
    city3:setPosition(cityPosition)
    city3:setScale(0.5)
    city3:setTileX(2.3)

    local city2 = ScrollingSprite:create("Images/UI/MainMenu/BG_city02.png")
    city2:setAnchorPoint(ccp(0.0, 0.0))
    city2:setPosition(cityPosition)
    city2:setScale(0.5)
    city2:setTileX(2.3)

    local city1 = ScrollingSprite:create("Images/UI/MainMenu/BG_city01.png")
    city1:setAnchorPoint(ccp(0.0, 0.0))
    city1:setPosition(cityPosition)
    city1:setScale(0.5)
    city1:setTileX(2.3)

    cutscene:addChild(sky)
    cutscene:addChild(city3)
    cutscene:addChild(city2)
    cutscene:addChild(city1)
    cutscene:addChild(water)

    local background1 = CCSprite:create("Images/UI/Cutscenes/panel_gym01.png")
    background1:setOpacity(0)
    background1:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(36.0, 162.5)))
    background1:setScale(0.5)
    cutscene:addChild(background1)

    local hawkFace = CCSprite:create("Images/UI/Cutscenes/panel_hawk_portrait.png")
    hawkFace:setOpacity(0)
    hawkFace:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(105.5, 176.0)))
    hawkFace:setScale(0.25)
    cutscene:addChild(hawkFace)

    local sidFace = CCSprite:create("Images/UI/Cutscenes/panel_sid_portrait.png")
    sidFace:setOpacity(0)
    sidFace:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-87.0, 169.0)))
    sidFace:setScale(0.25)
    cutscene:addChild(sidFace)

    local background2 = CCSprite:create("Images/UI/Cutscenes/panel_speedlines.png")
    background2:setOpacity(0)
    background2:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(228.0, 178.0)))
    background2:setScale(0.5)
    cutscene:addChild(background2)

    local hawkPunch = CCSprite:create("Images/UI/Cutscenes/panel_hawkpunch.png")
    hawkPunch:setOpacity(0)
    hawkPunch:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(60.0, 166.0)))
    hawkPunch:setScale(0.5)
    cutscene:addChild(hawkPunch)

    local tucoPanel1 = CCSprite:create("Images/UI/Cutscenes/panel_tuco01.png")
    tucoPanel1:setOpacity(0)
    tucoPanel1:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-92.0, 170.0)))
    tucoPanel1:setScale(0.25)
    cutscene:addChild(tucoPanel1)

    local tucoPanel2 = CCSprite:create("Images/UI/Cutscenes/panel_tuco02.png")
    tucoPanel2:setOpacity(0)
    tucoPanel2:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(105.5, 170.0)))
    tucoPanel2:setScale(0.25)
    cutscene:addChild(tucoPanel2)

    local background3 = CCSprite:create("Images/UI/WhitePixel.png")
    background3:setColor(ccc3(0, 0, 0))
    background3:setOpacity(0)
    background3:setPosition(UIUtil:getAlignPositionInParent(cutscene, UIUtil.MIDDLE_CENTER))
    background3:setScaleX(cutscene:getContentSize().width)
    background3:setScaleY(cutscene:getContentSize().height)
    cutscene:addChild(background3)

    local caption = CCLabelBMFont:create(LocalString:get("CutsceneIntroOneHourLater"):getCString(), "Fonts/title128.fnt")
    caption:setColor(ccc3(253, 242, 175))
    caption:setOpacity(0)
    caption:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.MIDDLE_CENTER), ccp(0.0, 19.0)))
    caption:setScale(0.25)
    cutscene:addChild(caption)

    local background4 = CCSprite:create("Images/UI/Cutscenes/panel_gym02.png")
    background4:setOpacity(0)
    background4:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(36.0, 169.0)))
    background4:setScale(0.5)
    cutscene:addChild(background4)

    local brickFace = CCSprite:create("Images/UI/Cutscenes/panel_brick_portrait_mirrored.png")
    brickFace:setOpacity(0)
    brickFace:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-87.0, 188.0)))
    brickFace:setScale(0.25)
    cutscene:addChild(brickFace)

    local brookeFace = CCSprite:create("Images/UI/Cutscenes/panel_brooke_portrait03.png")
    brookeFace:setOpacity(0)
    brookeFace:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(105.5, 148.0)))
    brookeFace:setScale(0.25)
    cutscene:addChild(brookeFace)

    local wall = CCSprite:create("Images/UI/Gym/background.png")
    wall:setOpacity(0)
    wall:setAnchorPoint(ccp(0.5, 0.0))
    wall:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(10.0, 82.5)))
    wall:setScale(0.5)
    cutscene:addChild(wall)

    local map = CCSprite:create("Images/UI/Cutscenes/panel_map.png")
    map:setOpacity(0)
    map:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-73.0, 183.0)))
    map:setScale(0.5)
    cutscene:addChild(map)

    local woodFloor = CCSprite:create("Images/UI/Cutscenes/panel_woodfloor.png")
    woodFloor:setOpacity(0)
    woodFloor:setAnchorPoint(ccp(0.5, 1.0))
    woodFloor:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(12.0, 120.5)))
    woodFloor:setScale(0.5)
    cutscene:addChild(woodFloor)

    local coach = CCSprite:create("Images/UI/Cutscenes/panel_coach_front.png")
    coach:setOpacity(0)
    coach:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-126.5, 153.0)))
    coach:setScale(0.5)
    cutscene:addChild(coach)

    local brooke = CCSprite:create("Images/UI/Cutscenes/panel_brooke_back.png")
    brooke:setOpacity(0)
    brooke:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(199.5, 141.0)))
    brooke:setScale(0.5)
    cutscene:addChild(brooke)

    local brick = CCSprite:create("Images/UI/Cutscenes/panel_brick_back.png")
    brick:setOpacity(0)
    brick:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(98.5, 138.5)))
    brick:setScale(0.5)
    cutscene:addChild(brick)

    local brickFace2 = CCSprite:create("Images/UI/Cutscenes/panel_brick_portrait.png")
    brickFace2:setOpacity(0)
    brickFace2:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_RIGHT), ccp(-203.0, 212.5)))
    brickFace2:setScale(0.25)
    cutscene:addChild(brickFace2)

    local brookeFace2 = CCSprite:create("Images/UI/Cutscenes/panel_brooke_portrait.png")
    brookeFace2:setOpacity(0)
    brookeFace2:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_RIGHT), ccp(-91.5, 138.5)))
    brookeFace2:setScale(0.25)
    cutscene:addChild(brookeFace2)

    local darkness = CCSprite:create("Images/UI/WhitePixel.png")
    darkness:setColor(ccc3(0, 0, 0))
    darkness:setPosition(UIUtil:getAlignPositionInParent(cutscene, UIUtil.MIDDLE_CENTER))
    darkness:setScaleX(cutscene:getContentSize().width)
    darkness:setScaleY(cutscene:getContentSize().height)
    cutscene:addChild(darkness)

    coroutine.yield()

    sky:startScrolling(-4.0, true);
    city3:startScrolling(-6.0, true);
    city2:startScrolling(-8.0, true);
    city1:startScrolling(-10.0, true);
    water:startScrolling(-12.0, true);

    darkness:setOpacity(255)
    darkness:runAction(CCFadeTo:create(FADE_IN_DURATION, 0))

    AudioManager:postEvent("Cutscene_Intro_01_Start")
    cutscene:clearSpeaker()
    cutscene:setText("CutsceneIntroCity1")

    coroutine.yield()
    
    AudioManager:postEvent("Menu_Button_Click")
    cutscene:clearSpeaker()
    cutscene:setText("CutsceneIntroCity2")

    coroutine.yield()

    sky:setOpacity(0)
    city3:setOpacity(0)
    city2:setOpacity(0)
    city1:setOpacity(0)
    water:setOpacity(0)
    background1:setOpacity(255)

    darkness:setOpacity(255)
    darkness:runAction(CCFadeTo:create(FADE_IN_DURATION, 0))

    background1:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-36.0, 162.5))))

    AudioManager:postEvent("Cutscene_Intro_02_Sid")
    cutscene:setSpeaker("Sid")
    cutscene:setText("CutsceneIntroSid1")

    coroutine.yield()

    local popUpAction1 = CCSpawn:createWithTwoActions(CCFadeTo:create(0.1, 255), CCEaseElasticOut:create(CCScaleTo:create(0.4, 0.5), 0.3))

    hawkFace:runAction(popUpAction1)

    AudioManager:postEvent("Cutscene_Intro_03_Hawk")
    cutscene:setSpeaker("Hawk")
    cutscene:setText("CutsceneIntroHawk1")

    coroutine.yield()

    local popUpAction2 = CCSpawn:createWithTwoActions(CCFadeTo:create(0.1, 255), CCEaseElasticOut:create(CCScaleTo:create(0.4, 0.5), 0.3))

    sidFace:runAction(popUpAction2)

    AudioManager:postEvent("Cutscene_Intro_04_Sid")
    cutscene:setSpeaker("Sid")
    cutscene:setText("CutsceneIntroSid2")

    coroutine.yield()

    local popUpAction3 = CCSpawn:createWithTwoActions(CCFadeTo:create(0.1, 255), CCEaseElasticOut:create(CCScaleTo:create(0.4, 0.5), 0.3))

    hawkFace:setScale(0.4)
    hawkFace:runAction(popUpAction3)

    AudioManager:postEvent("Cutscene_Intro_05_Hawk")
    cutscene:setSpeaker("Hawk")
    cutscene:setText("CutsceneIntroHawk2")

    coroutine.yield()

    background1:setOpacity(0)
    hawkFace:setOpacity(0)
    sidFace:setOpacity(0)
    background2:setOpacity(255)
    hawkPunch:setOpacity(255)

    darkness:setOpacity(255)
    darkness:runAction(CCFadeTo:create(FADE_IN_DURATION, 0))

    background2:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-228.0, 178.0))))
    hawkPunch:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-60.0, 166.0))))

    AudioManager:postEvent("Cutscene_Intro_06_Hawk")
    cutscene:setSpeaker("Hawk")
    cutscene:setText("CutsceneIntroHawk3")

    coroutine.yield()

    local popUpAction4 = CCSpawn:createWithTwoActions(CCFadeTo:create(0.1, 255), CCEaseElasticOut:create(CCScaleTo:create(0.4, 0.5), 0.3))

    tucoPanel1:runAction(popUpAction4)

    AudioManager:postEvent("Cutscene_Intro_07_Brute")
    cutscene:setSpeaker("Tuco")
    cutscene:setText("CutsceneIntroBrute1")

    coroutine.yield()

    local popUpAction5 = CCSpawn:createWithTwoActions(CCFadeTo:create(0.1, 255), CCEaseElasticOut:create(CCScaleTo:create(0.4, 0.5), 0.3))

    tucoPanel2:runAction(popUpAction5)

    AudioManager:postEvent("Cutscene_Intro_08_Brute")
    cutscene:setSpeaker("Hawk")
    cutscene:setText("CutsceneIntroHawk4")

    coroutine.yield()

    background2:setOpacity(0)
    hawkPunch:setOpacity(0)
    tucoPanel1:setOpacity(0)
    tucoPanel2:setOpacity(0)
    background3:setOpacity(255)
    caption:setOpacity(255)

    darkness:setOpacity(255)
    darkness:runAction(CCFadeTo:create(FADE_IN_DURATION, 0))

    AudioManager:postEvent("Cutscene_Intro_09_Transition")
    cutscene:clearSpeaker()
    cutscene:clearText()

    coroutine.yield()

    background3:setOpacity(0)
    caption:setOpacity(0)
    background4:setOpacity(255)

    darkness:setOpacity(255)
    darkness:runAction(CCFadeTo:create(FADE_IN_DURATION, 0))

    background4:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-20.0, 169.0))))

    AudioManager:postEvent("Cutscene_Intro_10_Brooke")
    cutscene:setSpeaker("Brooke")
    cutscene:setText("CutsceneIntroBrooke1")

    coroutine.yield()

    local popUpAction6 = CCSpawn:createWithTwoActions(CCFadeTo:create(0.1, 255), CCEaseElasticOut:create(CCScaleTo:create(0.4, 0.5), 0.3))

    brickFace:runAction(popUpAction6)

    AudioManager:postEvent("Cutscene_Intro_11_Brick")
    cutscene:setSpeaker("Brick")
    cutscene:setText("CutsceneIntroBrick1")

    coroutine.yield()

    local popUpAction7 = CCSpawn:createWithTwoActions(CCFadeTo:create(0.1, 255), CCEaseElasticOut:create(CCScaleTo:create(0.4, 0.5), 0.3))

    brookeFace:runAction(popUpAction7)

    AudioManager:postEvent("Cutscene_Intro_12_Brooke")
    cutscene:setSpeaker("Brooke")
    cutscene:setText("CutsceneIntroBrooke2")

    coroutine.yield()

    local popUpAction8 = CCSpawn:createWithTwoActions(CCFadeTo:create(0.1, 255), CCEaseElasticOut:create(CCScaleTo:create(0.4, 0.5), 0.3))

    brickFace:setScale(0.4)
    brickFace:runAction(popUpAction8)

    AudioManager:postEvent("Cutscene_Intro_13_Brick")
    cutscene:setSpeaker("Brick")
    cutscene:setText("CutsceneIntroBrick2")

    coroutine.yield()

    background4:setOpacity(0)
    brickFace:setOpacity(0)
    brookeFace:setOpacity(0)
    wall:setOpacity(255)
    map:setOpacity(255)
    woodFloor:setOpacity(255)
    coach:setOpacity(255)
    brooke:setOpacity(255)
    brick:setOpacity(255)

    darkness:setOpacity(255)
    darkness:runAction(CCFadeTo:create(FADE_IN_DURATION, 0))

    wall:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(0.0, 82.5))))
    map:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-83.0, 183.0))))
    woodFloor:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(0.0, 120.5))))
    coach:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-138.5, 153.0))))
    brooke:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(176.5, 141.0))))
    brick:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(69.5, 138.5))))

    AudioManager:postEvent("Cutscene_Gym")
    AudioManager:postEvent("Cutscene_Coach")
    cutscene:setSpeaker("Coach")
    cutscene:setText(cutscene:getKey() .. "Coach")

    coroutine.yield()

    local popUpAction1 = CCSpawn:createWithTwoActions(CCFadeTo:create(0.1, 255), CCEaseElasticOut:create(CCScaleTo:create(0.4, 0.5), 0.3))

    brickFace2:runAction(popUpAction1)

    AudioManager:postEvent("Cutscene_Brick")
    cutscene:setSpeaker("Brick")
    cutscene:setText(cutscene:getKey() .. "Brick")

    coroutine.yield()

    local popUpAction2 = CCSpawn:createWithTwoActions(CCFadeTo:create(0.1, 255), CCEaseElasticOut:create(CCScaleTo:create(0.4, 0.5), 0.3))

    brookeFace2:runAction(popUpAction2)

    AudioManager:postEvent("Cutscene_Brooke")
    cutscene:setSpeaker("Brooke")
    cutscene:setText(cutscene:getKey() .. "Brooke")

    coroutine.yield()

    AudioManager:postEvent("Cutscene_Done")

    -- Cleanup code here
end

function runEndingCutscene(cutscene)
    local wall1 = CCSprite:create("Images/UI/Cutscenes/panel_ending01.png")
    wall1:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(36.0, 193.5)))
    wall1:setScale(0.5)
    cutscene:addChild(wall1)

    local hawkFace = CCSprite:create("Images/UI/Cutscenes/panel_hawk_portrait2.png")
    hawkFace:setOpacity(0)
    hawkFace:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-87.0, 176.0)))
    hawkFace:setScale(0.25)
    cutscene:addChild(hawkFace)

    local brickFace = CCSprite:create("Images/UI/Cutscenes/panel_brick_portrait.png")
    brickFace:setOpacity(0)
    brickFace:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(105.5, 148.0)))
    brickFace:setScale(0.25)
    cutscene:addChild(brickFace)

    local wall2 = CCSprite:create("Images/UI/Cutscenes/panel_ending02.png")
    wall2:setOpacity(0)
    wall2:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(8.0, 193.5)))
    wall2:setScale(0.5)
    cutscene:addChild(wall2)

    local coachSide = CCSprite:create("Images/UI/Cutscenes/panel_coach_side.png")
    coachSide:setOpacity(0)
    coachSide:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-65.0, 143.5)))
    coachSide:setScale(0.5)
    cutscene:addChild(coachSide)

    local brookeSide = CCSprite:create("Images/UI/Cutscenes/panel_brooke_side.png")
    brookeSide:setOpacity(0)
    brookeSide:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(110.0, 159.5)))
    brookeSide:setScale(0.5)
    cutscene:addChild(brookeSide)

    local wall3 = CCSprite:create("Images/UI/Cutscenes/panel_ending03.png")
    wall3:setOpacity(0)
    wall3:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(20.0, 177.5)))
    wall3:setScale(0.5)
    cutscene:addChild(wall3)

    local brickHawkBack = CCSprite:create("Images/UI/Cutscenes/panel_brickNhawk_back.png")
    brickHawkBack:setOpacity(0)
    brickHawkBack:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-100.0, 137.5)))
    brickHawkBack:setScale(0.5)
    cutscene:addChild(brickHawkBack)

    local brookeBack = CCSprite:create("Images/UI/Cutscenes/panel_brooke_back.png")
    brookeBack:setOpacity(0)
    brookeBack:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(214.0, 144.5)))
    brookeBack:setScale(0.5)
    cutscene:addChild(brookeBack)

    local coachBack = CCSprite:create("Images/UI/Cutscenes/panel_coach_back.png")
    coachBack:setOpacity(0)
    coachBack:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(112.0, 124.5)))
    coachBack:setScale(0.5)
    cutscene:addChild(coachBack)

    local brickHawkFace = CCSprite:create("Images/UI/Cutscenes/panel_brickNhawk.png")
    brickHawkFace:setOpacity(0)
    brickHawkFace:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-78.0, 199.5)))
    brickHawkFace:setScale(0.25)
    cutscene:addChild(brickHawkFace)

    local brookeFace = CCSprite:create("Images/UI/Cutscenes/panel_brooke_portrait02.png")
    brookeFace:setOpacity(0)
    brookeFace:setPosition(ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(127.0, 142.0)))
    brookeFace:setScale(0.25)
    cutscene:addChild(brookeFace)

    local darkness = CCSprite:create("Images/UI/WhitePixel.png")
    darkness:setColor(ccc3(0, 0, 0))
    darkness:setOpacity(255)
    darkness:setPosition(UIUtil:getAlignPositionInParent(cutscene, UIUtil.MIDDLE_CENTER))
    darkness:setScaleX(cutscene:getContentSize().width)
    darkness:setScaleY(cutscene:getContentSize().height)
    cutscene:addChild(darkness)

    coroutine.yield()

    darkness:setOpacity(255)
    darkness:runAction(CCFadeTo:create(FADE_IN_DURATION, 0))

    wall1:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-36.0, 193.5))))

    AudioManager:postEvent("Cutscene_Ending_01_Start")
    cutscene:setSpeaker("Hawk")
    cutscene:setText("CutsceneFinalHawk1")

    coroutine.yield()

    local popUpAction1 = CCSpawn:createWithTwoActions(CCFadeTo:create(0.1, 255), CCEaseElasticOut:create(CCScaleTo:create(0.4, 0.5), 0.3))

    hawkFace:runAction(popUpAction1)

    AudioManager:postEvent("Cutscene_Ending_02_Hawk")
    cutscene:setSpeaker("Hawk")
    cutscene:setText("CutsceneFinalHawk2")

    coroutine.yield()

    local popUpAction2 = CCSpawn:createWithTwoActions(CCFadeTo:create(0.1, 255), CCEaseElasticOut:create(CCScaleTo:create(0.4, 0.6), 0.3))

    brickFace:runAction(popUpAction2)

    AudioManager:postEvent("Cutscene_Ending_03_Brick")
    cutscene:setSpeaker("Brick")
    cutscene:setText("CutsceneFinalBrick1")

    coroutine.yield()

    wall1:setOpacity(0)
    hawkFace:setOpacity(0)
    brickFace:setOpacity(0)
    wall2:setOpacity(255)
    coachSide:setOpacity(255)
    brookeSide:setOpacity(255)

    darkness:setOpacity(255)
    darkness:runAction(CCFadeTo:create(FADE_IN_DURATION, 0))

    wall2:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-8.0, 193.5))))
    coachSide:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-89.0, 143.5))))
    brookeSide:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(70.0, 159.5))))

    AudioManager:postEvent("Cutscene_Ending_04_Coach")
    cutscene:setSpeaker("Coach")
    cutscene:setText("CutsceneFinalCoach1")

    coroutine.yield()

    wall2:setOpacity(0)
    coachSide:setOpacity(0)
    brookeSide:setOpacity(0)
    wall3:setOpacity(255)
    brickHawkBack:setOpacity(255)
    coachBack:setOpacity(255)
    brookeBack:setOpacity(255)

    darkness:setOpacity(255)
    darkness:runAction(CCFadeTo:create(FADE_IN_DURATION, 0))

    wall3:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-20.0, 177.5))))
    brickHawkBack:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(-170.0, 137.5))))
    brookeBack:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(144.0, 144.5))))
    coachBack:runAction(CCMoveTo:create(PARALLAX_DURATION, ccpAdd(UIUtil:getAlignPositionInParent(cutscene, UIUtil.BOTTOM_CENTER), ccp(32.0, 124.5))))

    AudioManager:postEvent("Cutscene_Ending_05_Coach")
    cutscene:setSpeaker("Coach")
    cutscene:setText("CutsceneFinalCoach2")

    coroutine.yield()

    local popUpAction3 = CCSpawn:createWithTwoActions(CCFadeTo:create(0.1, 255), CCEaseElasticOut:create(CCScaleTo:create(0.4, 0.5), 0.3))

    brickHawkFace:runAction(popUpAction3)

    AudioManager:postEvent("Cutscene_Ending_06_Brick")
    cutscene:setSpeaker("Brick")
    cutscene:setText("CutsceneFinalBrick2")

    coroutine.yield()

    local popUpAction4 = CCSpawn:createWithTwoActions(CCFadeTo:create(0.1, 255), CCEaseElasticOut:create(CCScaleTo:create(0.4, 0.5), 0.3))

    brookeFace:runAction(popUpAction4)

    AudioManager:postEvent("Cutscene_Ending_07_Brooke")
    cutscene:setSpeaker("Brooke")
    cutscene:setText("CutsceneFinalBrooke1")

    coroutine.yield()

    -- Cleanup code here
end

function runCutscene(cutscene)
    if cutscene:getKey() == "Cutscene1" then
        runIntroCutscene(cutscene)
    elseif cutscene:getKey() == "CutsceneFinal" then
        runEndingCutscene(cutscene)
    else
        runGymCutscene(cutscene)
    end
end