<-! LiveSampleObamaTest.html ->
enchant (); / / initialize
var newLieCheck = 9;
var oldLieCheck = 0; / /
var alertCount = 0;
window.onload = function () {
var game = new Game (320, 320); / / game stage
game.fps = 20;
game.onload = function () {
var Obama2 = new Sprite (64, 64);
game.rootScene.addChild (Obama2);
Obama2.frame = [0]; / / select sprite frame
Obama2.opacity = 0.0;
var Obama1 = new Sprite (64, 64); / / after Obama2 ensures Obama1 is on top initially
game.rootScene.addChild (Obama1);
Obama1.frame = [0]; / / select sprite frame
var Label4X = new Label ('Touch me!');
Label4X.x = 100;
Label4X.y = 80;
game.rootScene.addChild (Label4X);
game.rootScene.backgroundColor = '# FFF8DC';
Obama1.onenterframe = function () {
if (alertCount <4)
{
alert ("Obama1.onenterframe");
alertCount = alertCount +1;
Label4X.text = ("Obama1.x =" + Obama1.x);
}
if (Obama1.x <284 & Obama1.x> 280)
{
if (alertCount <4)
{
alert ("if (Obama1.x <288 & Obama1.x> 286)");
alertCount = alertCount +1;
}
}
/ * {
switch (oldLieCheck)
{
case 0 / / oldLieCheck
Obama1.opacity = 1.0;
Obama2.opacity = 0.0;
break;
}
newLieCheck = 0; / / do math random here
switch (newLieCheck)
{
case 0
Obama1.opacity = 0.0;
Obama2.opacity = 1.0;
break;
}
} / / If (Obama1.x <288 and
* /
}; / / Obama1.onenterframe = function ()
Obama1.tl.moveBy (288, 0, 60) / / move right
. ScaleTo (-1, 1, 10) / / turn left
. MoveBy (-288, 0, 90) / / move left
. ScaleTo (1, 1, 10) / / turn right
. Loop (); / / loop it
Obama2.tl.moveBy (288, 0, 90) / / move right
. ScaleTo (-1, 1, 10) / / turn left
. MoveBy (-288, 0, 90) / / move left
. ScaleTo (1, 1, 10) / / turn right
. Loop (); / / loop it
};
game.start (); / / start your game!
};