Created
March 11, 2014 14:10
-
-
Save shiwano/9486432 to your computer and use it in GitHub Desktop.
Titanium サンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Globals = Alloy.Globals | |
SceneController = require 'common/controllers/scene' | |
class exports.Controller extends SceneController | |
name: Globals.Consts.Scenes.Start | |
events: | |
'click startButton': 'moveToHome' | |
'click optionButton': 'moveToOption' | |
initialize: -> | |
Globals.musicManager.play 'start' | |
moveToHome: -> | |
Globals.musicManager.stop() | |
Globals.Util.initializeModels() | |
Globals.sceneManager.moveTo Globals.Consts.Scenes.Home | |
moveToOption: -> | |
Globals.sceneManager.moveTo Globals.Consts.Scenes.Option | |
exports.controller = new exports.Controller($, arguments[0] or {}) unless GRUNT_ENV? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
helper = require('../../../test_helper') | |
Globals = Alloy.Globals | |
describe 'StartSceneController', -> | |
beforeEach -> | |
helper.beforeEach false | |
@subject = Globals.Util.createController 'start/scene' | |
afterEach -> | |
helper.afterEach() | |
describe '#initialize', -> | |
it 'should play "start" music', -> | |
expect(Globals.musicManager.name).to.be.equal 'start' | |
describe '#moveToHome', -> | |
beforeEach -> | |
sinon.spy Globals.Util, 'initializeModels' | |
sinon.spy Globals.musicManager, 'stop' | |
@subject.moveToHome() | |
afterEach -> | |
Globals.Util.initializeModels.restore() | |
Globals.musicManager.stop.restore() | |
it 'should initialize models', -> | |
expect(Globals.Util.initializeModels.called).to.be.ok | |
it 'should stop music', -> | |
expect(Globals.musicManager.stop.called).to.be.ok | |
it 'should move to home scene', -> | |
expect(Globals.sceneManager.currentScene.name).to.be.equal Globals.Consts.Scenes.Home | |
describe '#moveToOption', -> | |
beforeEach -> | |
@subject.moveToOption() | |
it 'should move to option scene', -> | |
expect(Globals.sceneManager.currentScene.name).to.be.equal Globals.Consts.Scenes.Option |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'#title': | |
top: 64 | |
font: | |
fontSize: 32 | |
fontFamily: 'M+ 2p' | |
'#startButton': | |
width: 192 | |
height: 64 | |
'#optionButton': | |
width: 160 | |
height: 48 | |
bottom: 8 | |
font: | |
fontSize: 14 | |
fontFamily: 'M+ 2p' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Alloy> | |
<View class="container"> | |
<View class="header"> | |
<Label class="sceneName">タイトル</Label> | |
</View> | |
<Label id="title" class="label">ああああ</Label> | |
<Button id="startButton" class="button">ゲームスタート</Button> | |
<Button id="optionButton" class="button">オプション</Button> | |
</View> | |
</Alloy> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment