Jump to content


Setting a Static TransformAroundPoint Location

Moderator Tag

Recommended Posts

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.

Link to comment
Share on other sites



I've read this post a few times, before and after the edit (with graphic) and I'm having a rough time understanding what needs to happen.


I think it would be very helpful if you could provide a simple file that clearly illustrates what isn't happening. It is very important that this file does not contain a lot of game logic or interactivity. Just something super simple.


I'm sure it will help us quickly assess if the plugin is performing as it should or if it was designed to handle your special use case.



Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.