Last active
September 8, 2017 01:43
-
-
Save albertochiwas/a3d5ba0e6f93cea2cfa3445b0925e13e to your computer and use it in GitHub Desktop.
Usando arreglo de objetos para animaciones (ver 0.3)
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 av = new Avatar(0); | |
var mov = [ // coreografia | |
[ // paso 1 | |
{scale:0.3, rotate:10, x:200, y:200}, | |
{a:1,g:45}, {a:3,g:-43}, {a:5, g:5} | |
], | |
[ // paso 2 | |
{scale:0.5, rotate:0, x:210, y:210}, | |
{a:1,g:90}, {a:3,g:-88}, {a:5,g:10} | |
], | |
[ // paso 3 | |
{scale:0.7, rotate:-10, x:200, y:200}, | |
{a:1,g:105}, {a:3,g:-102}, {a:5,g:5} | |
], | |
[ // paso 4 | |
{scale:0.9, rotate:0, x:190, y:210}, | |
{a:1,g:128}, {a:3,g:-126}, {a:5,g:0} | |
] | |
]; | |
var paso=0, inc=1, maxp=mov.length, pausa=false; | |
frameRate(2); | |
var draw = function() { | |
if ( paso<0 ) { inc=1; paso=0; } //.3 end-dec | |
if ( paso>=maxp ) { inc=-1; paso=maxp-1; } //.3 end-inc | |
background(255, 200, 0); | |
var sim = mov[paso]; | |
paso += inc; | |
for (var i=1; i<sim.length; i++) { | |
var pos = sim[i]; | |
av.setAngle(pos.a,pos.g); | |
} | |
var f = sim[0]; | |
av.scale(f.scale); | |
av.rotateAvatar(f.rotate); | |
av.draw(f.x,f.y); | |
av.scale(1.0/f.scale); | |
}; | |
var mouseClicked = function() { //.3 (des)congela animacion | |
if (pausa) { loop(); } else { noLoop(); } | |
pausa = !pausa; | |
}; |
reneariash
commented
Sep 8, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment