Skip to content

Instantly share code, notes, and snippets.

@fenixkim
Last active December 12, 2015 12:19
Show Gist options
  • Save fenixkim/4770935 to your computer and use it in GitHub Desktop.
Save fenixkim/4770935 to your computer and use it in GitHub Desktop.
import com.greensock.TweenMax;
import fl.motion.easing.*;
stop();
var splatSounds:Array = [new SplatSound1(), new SplatSound2()];
function crearSapoPintable(color1, color2, xPos, yPos) {
var sapo = new Sapos();
sapo.addEventListener(MouseEvent.CLICK, intercambiar);
sapo.colorActual = color1;
sapo.color1 = color1;
sapo.color2 = color2;
sapo.gotoAndStop(color1);
sapo.x = xPos;
sapo.y = yPos;
addChild(sapo);
sapo.splats.visible = false;
return sapo;
}
function intercambiar (event) {
var sapo = event.currentTarget;
if (sapo.colorActual == sapo.color1) {
sapo.colorActual = sapo.color2;
} else {
sapo.colorActual = sapo.color1;
}
sapo.splats.gotoAndStop(sapo.colorActual);
sapo.gotoAndStop(sapo.colorActual);
// Splat
TweenMax.killTweensOf(sapo.splats);
sapo.splats.visible = true;
sapo.splats.alpha = 1;
sapo.splats.scaleX = 0.7;
sapo.splats.scaleY = 0.7;
sapo.splats.rotation = randomInt(0, 360);
TweenMax.to(sapo.splats, 0.7, {autoAlpha:0, scaleX:1, scaleY:1});
splatSounds[randomInt(0, 1)].play();
}
function randomInt(min:int, max:int) : int{
return min + Math.round(Math.random() * (max-min));
}
crearSapoPintable("pink", "blue", 100, 80);
crearSapoPintable("blue", "pink", 220, 80);
crearSapoPintable("pink", "blue", 340, 80);
crearSapoPintable("pink", "blue", 100, 220);
crearSapoPintable("blue", "pink", 220, 220);
crearSapoPintable("pink", "blue", 340, 220);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment