I have a movie clip as you can see from the following link : http://prntscr.com/2pta2j .The registration point of it is in A, i.e. + symbol. I want to know where will be the registration point after I rotate it 90 degree . Final view of it will be like : http://prntscr.com/2ptans
The registration point stays next to A.
EDIT
One exception being, if the registration point next to A is the registration point of a container that the square is in and you rotate the square within the container, not the container.
Related
I have a group actor with a circle image .png and then I spread small circles around surface of this group, I mean circle on angle 0 and circle on angle 60 and so on using the math equation:
x=cx+radius*cos(theta);
y=cx+radius*sin(theta);
The problem now I apply rotate action (rotateBy Action)on the main group and I want to add circle actor to this rotated group when the user tab note: this circle actor is not yet child of the main circle rotated group. I want to add this actor to the rotated group and show to the user as it attached to point of collision with surface of circle of the main group. See the image.
Sorry for my bad English.
image before:
http://imgur.com/TwJ7ldA
image after:
http://imgur.com/kRxuxle
I guess its pure maths...
find the collision point coordinates relative to origin of the group(x_rel, y_rel)
than add the actor to the group
addActor(newBall);
newBall.setPosition(x_rel, y_rel);
Hey I am beginner Flash Action Script 3 developer.
I am using hitTestPoint() to detect collision between a car and a stage drawing. Car is moving in the stage so I am using hitTestPoint().
There is a problem, Lets say.
Car is a square, it is actually a perfect square right now.
I am doing this:
heightHalf = car.height / 2;
widthHalf = car.width / 2;
if(level.hitTestPoint(car.x + widthHalf, car.y + heightHalf,true)){
trace( "Right Collision" );
}
It should work as, car.x + the half of its with should return the point on x-axis which is colliding and same with the y-axis. But its not working.
When my car collides with the right walls it doesn't produce error or trace, but If I move my car further out of stage(as car can go through walls) just before it can completely move out, it produces trace error just when left side is colliding with walls.
These pics should help:
Right Collision with no error: http://i.minus.com/ibqvrbNHuLTTIX.png
Error but with wrong side: http://i.minus.com/iGRNRVmCwwY4x.png
Inverting the + - signs isn't helping either.
Take notice to where the anchor point is on the car object. since you are using Flash IDE, The anchor point could be in the middle, right, or left corner.
Also you will need multiple points do to this type of hitTesting. at least one for each side of car.
If your registration point is top left, then you are hitTesting the middle point of your car. So it will only register collision when half of the car goes over the wall.
Check your registration point. When you create a new movieClip or Sprite you can select the registration point by clicking one of the 9 box on the square that comes up under the name of the Object.
I have placed two movieclips one parent name "container" and a child inside container named holder. I want container to rotate by pressing/dragging the holder placed at the top right corner with mouse movement. The container should rotate from the center point.
Here on Stack Overflow, we do not work for you and code for you. We just answer productive questions that will help future users.
So what you would do is make a MouseEvent function and add the event to holder by container.holder.addEventListener(MouseEvent.MOUSE_CLICK...) and in the function you would put: addEventListener(Event.ENTER_FRAME...) and in that enter frame event, you would put: event.currentTarget.rotation += NUMBER or container.rotation += NUMBER - Same Thing because the event's current target is container. Replace NUMBER with a number.
Not much is being done here, as you can see:
Test link: http://bit.ly/Runmah
pick one item from left side for testing.
it's rotating when he find two intersect points on the line.
i want to move red rectangle within the polygon. It shouldn't go outside of polygon.
My code is: http://pastebin.com/pRMpk81f
Edit 1: http://pastebin.com/C3j4WSC1
If you know how to find the intersection of points on the line then you should be able to find distance between wall and furniture (line and edge of rectangle), you can check this value and for example stop draging and snap,
EDIT1:
when dragged item is selected (mouse is down) than you constantly check distance (e.g. on mouse move), then you can decide that if distance is within some threshold you will stop movement (basicaly you will set calculated position- snap - instead of applying mouse position) otherwise you will follow mouse.
EDIT2:
also you can test if the point is inside the shape by calculating intersection points - even number the point is outside, odd number - the point is inside
best regards
This should be fairly simple I'd think, I'm just not that familiar with actionscript haha.
I have a game where I have the background moving behind a character that stays in one position on screen. I'm relatively new to actionscript 3 but I'm wanting to have text boxes pop up whenever the player presses a key over certain objects passing in the background.
So, basically the background itself is a movie clip, and I have other graphics and movie clips within the background mc.
I was thinking of getting the player.x and y position and then "comparing" that position (>= and <=, etc.) with the graphic/movie clip in the background. But I just don't know how to obtain the x and y coordinate of the graphics/movie clips in the background mc.
You could try to target your movie clips in the background by getting their coordinates, then removing their parent's position (the background container).
Something like :
var finalXPosition:int = targetMovieClip.x - backgroundContainer.x;
var finalYPosition:int = targetMovieClip.y - backgroundContainer.y;
By substracting the target movieclip parent's position to its position, you gain the final position in the parent's scope coordinates.
It should work for you as soon as your character and your background container are situated at the same level of the display list.
Here is a quick diagram of what I try to explain (please forgive my inaptitude to draw nice and explicit drawings ^^)
Usually, when I stumble upon such a case, I try to make a quick and even dirty drawing, starting with what I want, then breaking down every useful data I have to achieve that result, you should keep that method in mind and try it the next time ! :-)