
jdrumm
-
Posts
3 -
Joined
-
Last visited
Content Type
Profiles
Forums
Store
Blog
Product
Showcase
FAQ
ScrollTrigger Demos
Downloads
Posts posted by jdrumm
-
-
Sure, the Point objects have x and y properties that you can access.
var random = Math.round(spawnPoint_Array.length * Math.random()); trace(spawnPoint_Array[random].y, spawnPoint_Array[random].y);
You can construct your tween like this:TweenMax.to(mc, 3, {startAt:{x:spawnPoint_Array[random].x, y:spawnPoint_Array[random].y}, x:end.x, y:end.y});
y:spawnPoint_Array[random].y}
y:spawnPoint_Array[random].y}
-
I'm trying to create a system of spawns for an as3 game. The goal is to have my enemy tweens spawn from one of the 4 different spawn points defined in the array of new Points, randomly. I've successful debugged my process so far, as the code at the very bottom illustrates.However, the problem comes when I attempt to enter my random spawn call into the starting point of the greensock tween. The code below shows if the random spawn call starts at the x value,that is to say: {startAt:{x:myArray[random]},the problem here is that when myArray[random] is called in that manner it's going to return both an x and a y value which of course is not going to work b/c both points are put into the x value of the tween, and separating the x and y values into two different arrays will call random x and y values, voiding my original intent of them spawning from a static point randomly.That being said, I'm asking if there is a way that I could combine both an x and y value in one placeso, in theory the tween I'm looking for might look like this:myTween = TweenMax.to(mc, 3, {startAt:{myArray[random]}, x:end.x, y:end.y});*notice how I want the starting point to be the randomly picked point in the array.* here is the idea put into action, but notice starting point below is { x:myArray[random] }var spawnPoint_Array:Array = [new Point(270, 808), //////// X and Y value of SPAWN 1new Point(-81, 768), //////// X and Y value of SPAWN 2new Point(1024, 768), //////// X and Y value of SPAWN 3new Point(566, 809)] //////// X and Y value of SPAWN 4var random = Math.round(spawnPoint_Array.length * Math.random()); //////picks a random spawn point
myTween = TweenMax.to(mc, 3, {startAt:{x:myArray[random]}, x:end.x, y:end.y});
*in the above tween, mc just refers to the movieclip name
Any ideas on how I would fix this problem?
Creating random spawning with static points
in GSAP (Flash)
Posted
Thanks for the assist. I was close, I was using:
x:spawnPoint_Array[randomize], y:spawnPoint_Array[randomize]
instead of:
x.spawnPoint_Array[randomize].x, y:spawnPoint_Array[randomize].y
all I needed was the .y and .x on the end of the random call,
Wow, I feel foolish.
Thanks for the answer.
YOU GUYS AT GREENSOCK ARE THE BEST, LOVE YOUR WORK.
"YOUR THE BEST AROUND, NO ONE'S GONNA EVER KEEP YA DOWN!"