Created
June 26, 2012 17:54
-
-
Save wesleyvicthor/2997472 to your computer and use it in GitHub Desktop.
just a sample code
This file contains hidden or 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
cardsDistribution: function() | |
{ | |
var self = this; | |
nusers = _env.stage.getChildById('main').getChildById('users_node').children.length; | |
ncards = nusers * 2; | |
for(var i=0; i<ncards; i++) { | |
var card = _utils.provider.getImage('images/back-card.png'); | |
card.x = _env.utils.CENTERX; | |
card.y = 80; | |
card.id = 'card_'+i; | |
_env.stage.getChildById('main').addChildAt(card, 20); | |
} | |
u = [ | |
{x:220, y:120}, | |
{x:125, y:169}, | |
{x:125, y:290}, | |
{x:220, y:325}, | |
{x:400, y:325}, | |
{x:575, y:325}, | |
{x:665, y:290}, | |
{x:665, y:169}, | |
{x:575, y:120} | |
]; | |
var x = 0; | |
var init = function(n) { | |
if(n > 8) { | |
var targetX = u[n - nusers].x - 3; | |
var targetY = u[n - nusers].y - 3; | |
} else { | |
var targetX = u[n].x; | |
var targetY = u[n].y; | |
} | |
var card = _env.stage.getChildById('main').getChildById('card_'+n); | |
var move = function() { | |
var posix = (targetX - card.x) * _env.utils.CARD_SPEED; | |
var posiy = (targetY - card.y) * _env.utils.CARD_SPEED; | |
card.x += posix; | |
card.y += posiy; | |
if(Math.abs(posiy) < 1) { | |
_env.stage.removeListener(doodle.events.Event.ENTER_FRAME, move); | |
if(++x < ncards) { | |
init(x); | |
} else { | |
_env.stage.frameRate = 2; | |
} | |
} | |
} | |
_env.stage.addListener(doodle.events.Event.ENTER_FRAME, move); | |
} | |
init(x); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment