ActionScript 3.0 :: Change The Rotation Point Of A Sprite?

Feb 4, 2008

I'm attempting to write a racing game. I've loaded in my image, I brought it to the stage and now, all I want to do is rotate it from its' center and not upper left corner.

The code:

racer.rotation += 5;

rotates from the upper left corner. How do I rotate from the center of the car/sprite? I've tried putting it into a container but I'm unsure on the coordinates of the container because I tried to set the x,y coordinates to half the sprite image but y'know, it's not doing what I expect it to.

ActionScript Code:
if (arrowLeft) {
var container:Sprite = new Sprite();

[Code]....

I will never sneer at another racing game! I didn't think it would be this hard to do a simple rotate of an image!

View 3 Replies


Similar Posts:


Actionscript 3 :: Moving A Point With Rotation Doesn't Change The Point XY?

Jul 15, 2011

i have the follow issue :

I have a point which is setted at the border on a component, with changed transform point to the center of a component in order to match the component rotation.

the important part is when i try to get the point XY after rotation - they remains the same as before rotation.

how to get XY, after rotation ( changeing point.rotation property to specific degrees of rotaion )

View 2 Replies

Flex :: Converting Sprite To Bitmapdata With A Different Registration Point And Rotation

May 22, 2011

I'm trying to convert a Sprite that I have into BitmapData so I can perform some collision detection. There are a few things about the way the Sprites are used that is making this more difficult than I expected:

The Sprite itself is a container which holds another Sprite that actually has a box drawn in it. The inner Sprite is positioned negative half its width & height so that it can be rotated from the center via the container. The container may be rotated at any angle at any given time

So my approach thus far has been attempting to draw the outer Sprite onto a new BitmapData object with a Matrix to account for the difference. Whilst I can use a Matrix to make this work for one particular rotation angle, I cannot find a way to make it work for any rotation.

Here's what I'm doing to draw onto the new BitmapData:

var p:Product = getProduct(); // Product is the container with the inner sprite
var bounds:Rectangle = p.getBounds(stage);
var bd:BitmapData = new BitmapData(bounds.width, bounds.height, true, 0x00FFFFFF);

[Code]....

Translating by the same amount as the previous example will no longer work here, and the box will still be cut off. I've looked around at some solutions posted before or suggestions from other people but they don't seem to work for me due to my container Sprite and rotation.

View 1 Replies

Flash :: Change 3D Registration Point For Rotation In AS3

Apr 18, 2011

Has anyone got a bit of code I can use to change the center point DisplayObjects rotate around in a 3D space? I need it to work with rotationX, rotationY and rotationZ. I know theres a workaround of wrapping every object in aother sprite and offsetting the x & y positions but I'd much prefer a math solution. As an example of the problem, this code should make a star shape:

[Code]...

View 1 Replies

ActionScript 3.0 :: Change The Rotational/scale Point On A Object/sprite?

Jul 31, 2009

When you load a object through flash, you can set the rotational/scale point, but when you load it as a loader object or sprite, how do you change this point?

In this instance, I want to change the height of a sprite that is filled with a rectangle so that it shrinks down, not up.

Right now:

var colored_bar:Sprite = new Sprite();
with (colored_bar.graphics) {
beginFill(0x9e1819, 1);

[Code]....

The way I am doing it currently is moving the y position everytime I take away soem of the height, so it looks like it's moving down, but I'd think moving the orientation point at the beginning would be faster

View 2 Replies

ActionScript 3.0 :: Off-center Rotation Of A Sprite?

Aug 19, 2010

As is well demonstrated by a Google search, the rotationX, rotationY, and rotationZ properties turn a display object around the center.

That's all well and good, but I want to rotate a display object about a different point.

I can't believe there isn't a way to do this, but I don't see anything that addresses this question specifically.

View 3 Replies

Actionscript 3 :: Sprite Rotation Around Center Error

Jul 6, 2011

I found this actionscript online to rotate a sprite around its center point but I get two errors when I use it. 1084: Syntax error: expecting identifier before leftparen. 1084: Syntax error: expecting rightparen before leftbrace. Also, in place of angleDegrees do I put in the angle I want the sprite to rotate by?

var point:Point=new Point(spr_box.x+spr_box.width/2, spr_box.y+spr_box.height/2);
rotateAroundCenter(spr_box,45);
function rotateAroundCenter (ob:*, angleDegrees) {
var m:Matrix=ob.transform.matrix;
m.tx -= point.x;

[Code]...

View 1 Replies

Dial In Anchor Point For 3D Rotation?

Jul 13, 2009

Flash knows where the anchor point is in 3D space in order for the symbol to rotate around it, but I can't seem to figure out how to see the coordinates of the anchor point or type in new ones. Please tell me how to do this. I am already very annoyed that Lynda, a pay service, doesn't think this is vital information. Apparently they think we would never want to do anything more visually stimulating than one simple spinning logo! But I digress...

Just to be clear, I know how to move the anchor point visually on the stage, but I want accuracy. I want to be able to give two symbols the exact same coordinates to rotate around.

View 3 Replies

ActionScript 3.0 :: Rotation Point Outside Of An Object?

Nov 9, 2009

Im using A

Code:
function enterFrameHandler(event:Event):void
{

[code]........

View 7 Replies

ActionScript 3.0 :: Set Rotation Center Point?

Jul 9, 2010

I am new in action script 3... i am not able to rotate movie clip from center point(movile clip is a containear holding many clips).

View 9 Replies

ActionScript 3.0 :: Rotation Around A Point, With Easing?

Jan 6, 2012

I have encountered a need to build what amount to classic boardgame spinner.

1. When you click on the spinner it spins clockwise

2. There are several places where it can stop.

When the user clicks the spinner I run a method to determine where (what target) it should stop on.

How can I make the spinner spin a few times, decrease in speed (ease) then stop at a certain angle?

View 3 Replies

ActionScript 2.0 :: Setting The Rotation Point?

Oct 26, 2004

i'm working on a flash game at the moment, and i would like to know if i am able to set the point that the movieclip rotates around using actionscript.

i don't want to do it by simply moving all of the contents of the movieclip closer or nearer. is there any other way of doing it? i couldn't find any simple functions for it. am i just going to have to use some complicated maths?

[edit] rotation point, aka, registration point.[/edit]

View 3 Replies

ActionScript 2.0 :: MovieClip Rotation Point?

Nov 14, 2007

I am making a 'simple' template builder in flash which allows the user to add/remove text boxes and images to the stage.
I can rotate any of the movieClips fine but it rotates from the top left and i want it to rotate from midpoint. Is there a way to set the midpoint/rotation point using actionscript?

View 1 Replies

Flash :: Rotation Reference Point Centering?

Jan 30, 2011

I have the following problem. I have an MovieClip in a holder MC. I would like to turn the inner MC X with 'rotation' parameter, and still keep it in the holder mc to the right and bottom of the holder MC reference point. So after turning it should look like thatanyone can tell me how to do that? Basically a function that takes any X rotated in any degrees through X.rotation = ... and puts it back in place in the holder MC.

View 3 Replies

ActionScript 3.0 :: Defining Rotation (pivot) Point

Sep 11, 2008

I am rotating some objects which their rotation (pivot) point is not at the center. My aim is to rotate from the center of the shape. How can I overcome this?

View 1 Replies

ActionScript 3.0 :: Rotation Around Internal Point On Click?

Sep 24, 2010

greetings, first of all sorry for my english. This question will probably looks more difficult than it is.

I have movieclip which I want to rotate around internal point few angles with click on certain button, and I manage to do it, but I want to see motion, or even put ease not only to immediately pop up in the place.

Code:
import flash.geom.Matrix;
import fl.motion.*;

[Code]...

View 5 Replies

ActionScript 3.0 :: Choose Rotation Point And Direction?

Nov 11, 2010

I am creating a a small site with a spinning menu but I want it to spin only in onedirection ( clockwise) and around the centre of the 3 point cross I am using as a menu.I have this currently to rotate the menu but I want it to only rotate on way and around centre.

Code:
content_mc.draw_btn.addEventListener(MouseEvent.CLICK,drawClick);
function drawClick(e:MouseEvent):void{

[code]....

View 2 Replies

ActionScript 2.0 :: Rotation Around Simulated Registration Point?

Oct 31, 2003

I want to have arm movement such as the forearm rotating about the arm where the elbow should be the problem is the registration point is at the shoulder for arm. I want the forearms registration to be constantly equal to a simulated registration point where the elbow should be as the arms registration point would be at the shoulder. I need to do it without nesting (a movieclip within another) is it possible. I tried using a constant distant between the two clips but it doesn't work. Don't know I have to use trigonometry or not

I think in brief what I trying to accomplish is
onEnterFrame=function(){
arm._x=shoulder._x
arm._y=shoulder._y
arm._x=simulated_x (where elbow would be)
arm._y=simulated_y (where elbow would be)
}

View 7 Replies

Actionscript 3 :: Applying Rotation Of Sprite To StartDrag()'s Rectangle Bounds

Apr 13, 2010

from my main class i call to create a sprite and add it to the stage

private function addSwatch(evt:MouseEvent):void
{
if (stage.getObjectsUnderPoint(mousePoint()).length == 0)
{

[Code]....

View 1 Replies

Professional :: 3D Rotation For Symbol About Y Axis Using Pivot Point

Nov 13, 2011

I am trying to rotate a symbol about the y-axis, 45 degrees one direction, then back to center, then 45 degrees the other direction. Seems like a relatively simple task, except here is what happens.

Here is the object with no rotation:
Here is the object rotated exactly 45 degrees:
And here is the object rotated exactly -45 degrees:

I need the object to rotate the same as it did the first time but in reverse, otherwise "45" and "-45" are generally worthless numbers to refer to. Is it something to do with the pivot point? I made sure the registration point was in the center when I created the symbol. It doesn't seem to be pivoting the object around the center though. How do I rotate about the y-axis using a pivot point that is actually in the center and gives the same (but opposite) effect when rotating it one way versus the other?

View 1 Replies

ActionScript 2.0 :: Random Rotation Around A Fixed (Central) Point

Jan 15, 2009

I have a project on the go which has a compass that I would like to have move randomly around a fixed central point (giving the idea of changing direction).Would anyone be able to help me out with the coding to get this to work?

View 1 Replies

ActionScript 3.0 :: Make Shape Rotation At It's Center Point?

Jun 14, 2011

I draw a shape,like follows:

var shape1:Shape;
shape1=draw();
addChild(shape1);
shape1.rotation=50;

[Code]....

Then I want to rotate the shape at it's center point(200,202) by using shape1.rotation=50,but I find the shape don't rotate at the the center of it's shape. How to realize the function which make shape rotate at its center point?

View 4 Replies

ActionScript 3.0 :: FP9/10 Enforces A Minimum Increment Or Resolution For The Sprite Rotation Property?

Aug 18, 2009

Does anyone know if AS3 or FP9/10 enforces a minimum increment or resolution for the Sprite rotation property?It seems to only allow rotations in multiples of 0.25 degrees.For example:

var lines:Array = new Array();
for (i=0; i<2000; i++){
lines[i] = new Shape();
lines[i].graphics.lineStyle(.1, 0x000000);

[code]...

This draws the lines in groups at 0.25 degree spacing with gaps between them.

View 2 Replies

Actionscript 3 :: Rotation Of A Line Based On Fixed Point In Flex4

Sep 27, 2011

As in the figure i have three lines out of which line1 and line2 are fixed. line3 is derived from line1 based on some angle say 70.I try to rotate the line3 but it deviate from the point x1 and x2. I try the code like this

[Code]...

View 2 Replies

Flex :: How To Know If Point Belong To Sprite

Mar 8, 2012

How can I know if a point is contained inside of an Sprite in Flex?

For example:
// My example point
var A:Point = new Point(5,5);
// My example sprite
var s:Sprite = new Sprite();
s.graphics.lineStyle(1,0x000000,1);
s.graphics.moveTo(0,0);
s.graphics.lineTo(100,100);

The point A belong to sprite s because its position is inside of it. Is there any function to know it? I want to do it for all kind of sprites, so use math formulas to calculate linear or quadratic equations (line, circle, rectangle, etc) is not valid for me.

View 1 Replies

Actionscript :: Count The X And Y Coordinates Of A Point From The Object's Rotation (angle) And Leg's Length?

Feb 2, 2012

how I can count the B point's coordinates (see attached image... or not as I am a new user...pf!). I know the arrow's rotation - so the angle (let's say it is -120), A's coordinates (0, 0) - A is the middle point of the arrow, and that the distance between A and B is 50 px.

View 1 Replies

ActionScript 3.0 :: Pan Sprite Which Changes Its Size And Registration Point?

Apr 26, 2009

i am succesfully panning an image so far with this code:

Code:
my_mc.addEventListener(Event.ENTER_FRAME, panMe);
function panMe(e:Event):void {

[code]....

View 10 Replies

Actionscript 3 :: Rotating A Sprite Around Its Center Point?

Aug 9, 2011

I searched online and found this script that is supposed to rotate and image but I'm not sure how to use, where to put in the degree angle that I want my sprites to rotate by. Also, I get an error. 1084: Syntax error: expecting identifier before leftparen. 1084: Syntax error: expecting rightparen before leftbrace.

var point:Point=new Point(spr_box.x+spr_box.width/2, spr_box.y+spr_box.height/2);
rotateAroundCenter(spr_box,45);
function rotateAroundCenter (ob:*, angleDegrees) {

[Cde].....

View 1 Replies

ActionScript 3.0 :: Find Most Left And Top Right Point In A Sprite?

Aug 8, 2009

I once needed to pan a sprite full of movieClips (picture 1) which were draggable with no bounds so you could drag them up and left (higher than sprites registration point).

You could also drag them down and right and expand a sprite that way (as well) but that didnt matter.What did matter was how much is 'up' and 'left' from the sprite registration point so i can include that in my formula for panning.

This was easy to find, i just sorted my array of movieClips, sorted on x and sorted on y after each drag, and thats how i got my up and left points.

Now I am trying to do that same thing, exept my movieclips inside a sprite have a custom rotation (picture 2), so i also have an up and left point, except this time up and left are caused by rotations of movieClips inside a sprite... (and these are dragable as well with no bounds)

View 1 Replies

Actionscript 3 :: Setting Anchor Point Of Sprite To Middle?

Mar 29, 2012

I am generating sprites programatically like this:

this.food = new Sprite();
this.food.graphics.beginFill(0xFFFFFF);
this.food.graphics.drawRect(0, 0, 10, 10);
this.food.filters = [new GlowFilter(0xFF6699, .80, 5, 5, 2, 2, false, false)];
this.food.graphics.endFill();

[Code]...

I basically want the food sprite to spin slowly about its center, not its x and y value which is the top left corner of the sprite. How can I make the anchor the center of the sprite?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved