Created
June 19, 2011 15:01
-
-
Save astronaughts/1034379 to your computer and use it in GitHub Desktop.
jaiken
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
var tabGroup = Titanium.UI.createTabGroup(); | |
var win = Titanium.UI.createWindow({ | |
backgroundColor: '#D8D8D8', | |
barColor: '#000000', | |
title: 'じゃいけん' | |
}); | |
var tab = Titanium.UI.createTab({ | |
window: win | |
}); | |
//------------------------------------------------------------------------------ | |
var you, enemy; | |
var GUU = 0; | |
var CHOKI = 1; | |
var PAA = 2; | |
var images = ['guu.gif', 'choki.gif', 'paa.gif']; | |
var jaiken = Titanium.UI.createImageView({ | |
height: 200, | |
width: 200, | |
top: 80, | |
duration: 50, | |
repeatCount: 0, | |
images: images, | |
backgroundImage: 'guu.gif' | |
}); | |
jaiken.addEventListener('stop', function() { | |
var result; | |
switch (enemy) { | |
case GUU: | |
result = you == PAA; | |
break; | |
case CHOKI: | |
result = you == GUU; | |
break; | |
case PAA: | |
result = you == CHOKI; | |
break; | |
} | |
if ( result ) { | |
alert('勝ち!'); | |
} else { | |
alert('負け!'); | |
} | |
}); | |
jaiken.addEventListener('change', function(e) { | |
enemy = e.index; | |
}); | |
win.add(jaiken); | |
var start = Ti.UI.createButton({ | |
width: 195, | |
height: 40, | |
top: 20, | |
left: 65, | |
title: 'START' | |
}); | |
start.addEventListener('click', function() { | |
jaiken.start(); | |
start.enabled = false; | |
}); | |
win.add(start); | |
function pon() { | |
jaiken.stop(); | |
start.enabled = true; | |
} | |
var yourGuu = Ti.UI.createButton({ | |
width: 50, | |
height: 50, | |
top: 300, | |
left: 60, | |
image: 'guu.gif' | |
}); | |
yourGuu.addEventListener('click', function() { | |
you = GUU; | |
pon(); | |
}); | |
var yourChoki = Ti.UI.createButton({ | |
width: 50, | |
height: 50, | |
top: 300, | |
left: 130, | |
image: 'choki.gif' | |
}); | |
yourChoki.addEventListener('click', function() { | |
you = CHOKI; | |
pon(); | |
}); | |
var yourPaa = Ti.UI.createButton({ | |
width: 50, | |
height: 50, | |
top: 300, | |
left: 200, | |
image: 'paa.gif' | |
}); | |
yourPaa.addEventListener('click', function() { | |
you = PAA; | |
pon(); | |
}); | |
win.add(yourGuu); | |
win.add(yourChoki); | |
win.add(yourPaa); | |
tabGroup.addTab(tab); | |
tabGroup.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
あいこは負けよ〜