“Working” example is here (this script deals with the triangle animation)
full code here: http://pastebin.com/rgPNxHgJ
This question is mainly about the proper syntax. I have the following:
shape.transitionTo({
offset: {
x: 10,
y: 10
}
})
What I want to do is have “x” and “y” be randomly selected from an array, for example:
movementIn = [
{x: 34, y: 66},
{x: -34, y: -66}
],
shape.transitionTo({
offset: movementIn[Math.floor(Math.random() * movementIn.length)],
});
But this doesn’t seem to be working… it seems to be only choosing the first item every time. Am I doing something wrong here?
how do I select a random X and Y pair and insert it into the “offset” parameter?
Thanks!
“Works for me”
Do note that this is not the “correct” way to pick one item as the distribution is slightly skewed ..
There are some syntax and semantical issues with the code in the question that should be explored:
I feel trolled, here you go: