Skip to content

Instantly share code, notes, and snippets.

@astronaughts
Created June 19, 2011 15:01
Show Gist options
  • Save astronaughts/1034379 to your computer and use it in GitHub Desktop.
Save astronaughts/1034379 to your computer and use it in GitHub Desktop.
jaiken
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();
@astronaughts
Copy link
Author

あいこは負けよ〜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment