Search In
• More options...
Find results that contain...
Find results in...

# Josh

Members

1

0

1. ## Setting a Static TransformAroundPoint Location

I'm very new to actionscript and currently working on a game in Flash for a class assignment. The teacher recommended tweening the objects in the game, like bullets, enemies, ect. So as an enemy behavior, I'm trying to tween it to approach the player as it travels in a circle, so that it would approach in a spiral, eventually colliding with the player if they failed to shoot it. After some searching, I've found the TransformAroundPoint addon, which is very helpful and almost what I'm looking for. TweenMax.to(enemy, 3, {x:player.x, y:player.y, ease:Linear.easeNone, transformAroundPoint:{point:new Point(player.x, player.y), rotation:360}}); So when this line executes, it does in fact rotate 360 around the player, but the point it rotates on is also tweened as the enemy moves towards the player. I've tried different combinations of code, and looked at the TransformAroundPoint plugin itself to see if I could modify it to work for my needs, but I'm just not experienced enough. If anyone knows how to define the transform point as an absolute position that does not tween, I would be very appreciative. Edit: I've attempted something else to get it to work, and despite what seems to be sound logic it fails. Here's a figure to understand what I'm trying to do better. As it stands, the player is the center black shooter (pointing to the right in this image). When the game runs it looks towards the mouse, and the two balls to the right and left of it rotate with it in a circle, always the same radius from the player (also note that the player cannot move, only look). The red circle is the Target, and that is what bullets fired from the player tween to, since you must tween to a location and not a distance (it helps avoid a lot of trig that was not working in earlier iterations). At the moment, enemies spawn from prevous target locations based on locations the player shot a bullet (a clever way to render them on the circle for testing purposes). Now, I theorized that since everything that resides within the transformAroundPoint plugin is self contained, and that it was being transformed across the screen to the player's location, why not have the inerior points move in an opposite and equal direction to the player. I implimented this with the blue dot, which also perfectly rotates around the player opposing the red dot, and updated the transformAroundPoint plugin to this: TweenMax.to(enemy, 3, {x:player.x, y:player.y, ease:Linear.easeNone, transformAroundPoint:{point:new Point(player.x, player.y), x:opposingTarget.x, y:opposingTarget.y, rotation:360}}); In this scenario, the enemy should move towards the player, while the interior tween the enemy rotates around the player while moving away. While the code complies, it stragely does the exact same thing it did before, despite the fact that if I replace the x and y destinations inside the plugin, it reloates the point to that location. Needless to say, this is rather bizzare, and if anyone has any advice I'd be happy to hear it.
×