ActionScript 2.0 :: Rotating Group Of Squares Around Point?

Feb 22, 2007

I'm actually coding this in Java (with which I have just a few days experience), but as far as the logic goes, I thought this would still be an appropriate place. I'm making a Tetris-eque game and having trouble with rotation. Each shape (rectangle, L, "step", etc) consists of 4 or 5 smaller squares (image below), and I want to be able to rotate the pattern of squares 0, 90, 180 and 270 degrees around a designated point.

x = originX + cos(angle) * radius;
y = originY + sin(angle) * radius;

I thought I understood these, but apparently not, since I can't seem to get it working� For each shape, I would declare the x, y coordinates for each of its smaller squares, relative to one another. Then, I'd send these values to a function that should take the pattern and rotate it according to the specified angle. In Java (to the best of my knowledge), the upper-left is always the "registration point" for graphics. So, I set the relative coordinates for the squares of each shape such that the left side of the leftmost square is at x = 0 and the top side of the uppermost square is at y = 0. Here's an example, the shape of a plus sign (+).

Code:
//top-center
x = squareWidth;
y = 0;

[code]....

no rotation (just the shapes)and this is what happens when I implement the rotation adjustment.

View 7 Replies


Similar Posts:


ActionScript 2.0 :: Group Of Squares - One Gets Bigger Others Small?

Nov 6, 2006

I am wondering what that effect is called or how to achieve it where let's say I have 6 squares, 3 on top, 3 on the bottom(2x3 matrix) and where if I click one, it gets bigger, and all the other ones get smaller. The problem here is the how they get bigger. If I click the middle square in the top row, it should stay in it's position and grow where as If If I click the bottom right one, it should grow towards the far left side. I'm guessing the registration point needs to be changed dynamically?

View 3 Replies

ActionScript 2.0 :: 3D With Flash - Make Rotating Squares Or Triangles?

Jan 25, 2002

what's the main idea behind 3D in Flash. I mean, I've seen a lot of scripts to make rotating squares or triangles or whatever, but never managed to understand how they were made.

View 14 Replies

ActionScript 3.0 :: Find Highest Point Of A Group Of Boxes?

Mar 31, 2009

I have a number of boxes on screen - each box is a rectangular movieclip, and they fall to the bottom of the screen where they pile up to make a stack of boxes. I'm using box2d for the physics. Oh, and each box may be rotated. I need to find the highest point - ie the smallest y value, of the stack of boxes.

Obviously I can find the position of the highest box's registration point easily (which is the centre of each box) - but that may not be the highest point of the pile of boxes. The highest point may not even be the highest box - it could be a lower box that is rotated on end, for example.

View 3 Replies

ActionScript 2.0 :: Rotating Around Point?

Jul 26, 2006

concept I can't wrap my mind around.If you've been the the sitehe has a "picture map"I've seen this used at other sites too.But what the rotation. The pictures always rotate around the point you click on.I just don't get it. I understand the momentum and all for the swing though

View 1 Replies

ActionScript 3.0 :: Rotating A 3d Point Around A 3D Line?

Jul 2, 2011

Line is defined by two 3d points; (0,0,0) and (x,y,z). And there is also this 3d point. How can rotate this 3d point around the line?

Something like this (points indicate vectors in my expression, it's the same thing) :

I found some stuff on the internet but I couldn't really figure it out.

View 6 Replies

ActionScript 1/2 :: Rotating A Movieclip In A Given X,y Point?

Dec 8, 2010

how can I make the green movieclip rotate in the point that the claw has catch it. To give an impression of physics. Here´s the image, to give you an idea:
 
The point (x,y) that the claw catches the colored movieclips below is not unique it can be any number. As long as the claw catches the colored movieclip.

View 13 Replies

IDE :: Images Rotating Around Center Point?

Dec 10, 2009

how to do an effect like the one seen on this page?: http:[url]....

View 1 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 :: Track A Point On Rotating MovieClip?

Feb 14, 2012

I have a MovieClip, that is representing a character in my game. Id like to "create bullets" shooting out from the tip of my characters gun. Problem is that when my character turns around, also the point rotates around the MovieClips pivot.

Is it possible to anyhow easily track this point, so that I could dynamically create new objects at the same location.

I tried to add a new MC as a child to my character, with the initial position at the guntip. In some systems child-objects "follow" their parents around, but it didnt seem to work here.

Is there any other "native" way of doing this, or do I just have to have a Polar-coordinates representation of the point relative to character-MovieClips origin, and add the MC rotation to theta, so that I can calculate the X and Y coordinates?

View 2 Replies

ActionScript 2.0 :: Rotating Object To Point Forward?

Jun 14, 2005

I'm working on creating an animation in which there are insects randomly moving around - based on tutorials on this site. Does anybody know how to make the insect rotate so that it always points towards the direction of travel.here's what's on my movie clip:

Code:
onClipEvent (load) {
scale = (random(100)+50);
this._alpha = random(50)+20;
this._xscale = scale;

[code]....

View 5 Replies

ActionScript 3.0 :: Rotating MovieClip To Point At Mouse

Jul 4, 2007

I am trying to make a line point to wherever the cursor is when I stumbled upon the Math.atan2(); function. It appeared that i would put
line.rotation = Math.atan2(1,1);
to get 45 degrees or pi/4, but I was wrong. It barely moved the movieclip at all. So what I'm trying to do is to get this movie clip to rotate along with the mouse so the line is always pointing at the cursor. Also, how would you get movieclip to move along the line created by the line of these two points?

View 9 Replies

ActionScript 3.0 :: Rotating A Circle To A Specific Point

Mar 6, 2009

What I'm trying to do is make a dial-type of interface, where you click on a point on the edge of a circle and that point will rotate to another point at the top of the circle. What I can't figure out is how the make "Point B" rotate to "Point A", where "Point A" is always fixed at the top of the circle and "Point B" (and Point C and Point D, etc...) are located along different points on the edge of the circle. I'm using the tween function to rotate, so what I need to figure out is how to get the difference in the rotation between the two points.

View 7 Replies

ActionScript 3.0 :: Rotating Point Around Center Of Circle

Mar 9, 2009

I am trying to rotate some points around the center of the circle(0,0), however I'm getting weird values from the output. I've commented the problem code..

Code:
var r:Number = 10;//radius
var y:Number;
var x:Number;
var a:Number = 90;//angle of which the semi-circle is facing.. could be a random angle.
var ax:Number;//rotated points
[Code] .....

I am using the semicircle in BitmapData collision checking with getPixel(), with a moving circle...

View 1 Replies

ActionScript 3.0 :: Rotating A Circular Set Of Links To A Specified Point/Angle?

Jan 27, 2010

I have a set of links (movie clips) arranged in a circle. When one of the links is clicked, I would like the circle of links to rotate until the selected link is in a certain position - straight down (90 degrees) in this case - and the others to maintain their positions relative to the clicked link (ie: they all move, but the distance between them is maintained). The behavior is intended to be like a bullet rotating into a chamber on a revolver, or - more accurately - like that of a Ferris Wheel. [URL] Here is my mangled version of the AS from the site linked above:

ActionScript Code:
// setting variables
var centerX = Stage.width/2;    // Stage Center X
var centerY = Stage.height/2;   // Stage Center Y

[code]....

View 7 Replies

ActionScript 3.0 :: Rotating Around Matrix Point To Specific Angle

Mar 5, 2010

I have a slider which I want to use to rotate an image around it's center. This normally is easy but my problem is the clip is made dynamically and the size changes so I can't use the default registration point and I need to assign the center point before I rotate it. I found the rotateAroundExternalPoint function which rotates around a center point fine. How to get it to rotate to a certain angle and then have it stop at that angle. The rotateAroundExternalPoint increments the rotation rather then allowing me to set the angle to rotate to. Is there anyway that I can set what angle to rotate my clip to? It right now increments the rotation by the x coordinate of my slider bar (slider_position.x).

Code:
import flash.geom.Matrix;
import fl.motion.*;
var mat:Matrix = clip.transform.matrix;
addEventListener(Event.ENTER_FRAME,EnterFrame3);
function EnterFrame3(event:Event) {
var center_point_x = clip.height / 2
var center_point_y = clip.width / 2 //
MatrixTransformer.rotateAroundExternalPoint(mat,center_point_x,center_point_y,slider_position.x);
clip.transform.matrix = mat;
}

View 9 Replies

ActionScript 2.0 :: Rotating A Movable Movieclp Around A Spcific Point?

May 2, 2010

I've been trying to figure this out for a while now and cannot get it to work. I have a movieclip that can be moved up, down, left and right with the arrow keys, and reflected/flipped using the arrow and control keys together. However, I want to be able to use the arrow keys and shift to rotate the movieclip about a point with x co-ordinate 230 and y co-ordinate 180, regardless as to whether or not the movie clip has been moved up, left, etc.I've tried several different codes based on examples I've found online, but none have worked. I cannot make sure the centre point of rotation never changes.

View 0 Replies

ActionScript 2.0 :: Rotating Draggable Point About Circumference Of Circle?

Mar 25, 2007

How to make a point rotate about the circumference of a circle upon dragging. How do I go about doing it? Is there something to do with the
startDrag(...); ?
From what I have right now, I can move the point but not on the circumference of the circle.

View 3 Replies

ActionScript 3.0 :: Rotating Around Center Point While Updating .x & .y Properties?

May 27, 2010

I want to be able to rotate the ship around the center point and be able to update the .x and .y at the same time.I've got this two versions of code.1

Code:
if (aKeyPress[38])
{

[code].....

View 2 Replies

Radiobutton Group Value - Get The SelectedData From The Group?

Aug 14, 2009

I've got some MC's in my library that have radiobuttons in them -- all of this created at design time -- and pull them onto the stage dynamically. My question is how do I get the selectedData from the group? The setup is like this: In a MC called pageOne, I have a group of buttons with a group name of Q1, Q2, etc. I pull the MC onto the stage like this:

[Code]...

Do I need instance names on each of the buttons and add listeners to all of them?

View 4 Replies

ActionScript 3.0 :: Delay Between A Group Of Leaves Falling And Next Group Falling?

Oct 17, 2010

I have some code here for some falling leaves. I was wondering how it can be altered so there is a delay between a group of leaves falling and the next group falling? also to slow down at the end of the fall? [code]

View 9 Replies

ActionScript 2.0 :: Rotating Menu With Non-Rotating Labels?

Nov 1, 2005

I have a rotating menu that sets the selected button to the 3:00 position once clicked. I need the labels for the buttons to stay in the upright position as they rotate with the button. I have attached an image. Anyone know of an action script that would keep the labels upright?

View 8 Replies

Transitioning One Image To Another Using A Grid Of Squares?

Jun 12, 2009

I'm trying to do a transition that you've probably seen many times. Transitioning one image to another using a grid of squares where each square fades at a slightly different time.I've made a complex movie clip made up of several other movie clips with all the squares fading at the rate I'm looking at. When I just play the color squares it works fine, but the minute I turn that master movie clip into a mask for the image I loose the transition/fade completely--just an on off thing.

View 3 Replies

ActionScript 3.0 :: Calculating Pixels In Squares?

Jan 27, 2009

I have a math issue that I have some problems solving.

screen1

screen2

I need to calulate the pixels inside the squares and put them inside an array:

The main square rotates(see screen2) and i have the angle.

Something like attached code.

I have the following values:

- x/y of the main square. ( reference point )

- Width/height of the main square

- Width/height of all the squares

- Angle of main square..

View 8 Replies

ActionScript 2.0 :: Arrange Squares In Column?

Apr 23, 2010

I have a problem with arranging some thumbs in column when I resize the stage. The problem is that it is arranging the last square in line half outside the stage and you can see only a half.

ActionScript Code:
stop();
Stage.align = "tl";
Stage.scaleMode = "noScale";

[code]....

View 0 Replies

Actionscript 3.0 :: Draw Squares With DrawTriangles?

Jan 25, 2010

How do you go about drawing only the outline of squares using drawTriangle. Currently I am using lineStyle to draw my lines but obviously that outlines each triangle. I know i can just draw Squares out using drawRect with no fill but that seems like a waste.

View 6 Replies

ActionScript 2.0 :: Hide Some (most) Of The Squares From View?

Feb 10, 2004

Now I could do with some hints as to how this should be done Hopefully someone will help me out here.

Ok, basically I have a map (a jpg/gif file), which should be divided into squares (like a chessboard). Each square has a coordinate (X, Y) and other pictures should be shown on top of a map square - like a small house or something (also a jpg/gif file).

It should also be possible to hide some (most) of the squares from view - like with a black square on top or whatever. Perhaps Flash should also make some lines between each square to divide them.

Furthermore only a part of the map should be shown through a window (using a mask, I guess) as the map could be large and buttons at the edge could be used to scroll the map.

View 3 Replies

IDE :: Link The Red Squares To The Blue Square In 3D With CS4 Only?

Feb 20, 2009

I would like to link the red squares to the blue square in 3D with CS4 only (please no papervision or sandy...)I'm very closed to the solution but I still have a wrong z (visible when you move the mouse to a corner for instance)

[code]....

The main function is drawLines()

View 1 Replies

ActionScript 3.0 :: All TextFields Displaying As Squares?

Mar 18, 2011

I learned about the date class yasterday and made a lil app that will tell me when the next recess at school will be. It worked great when I ran it at home, but now when I try to run it at school all the letters in the textfields displays as squares, the numbers still work tho. The only difference I can think of is that at home i use CS5 and at school is use CS4, the font is embedded in the fla.

View 4 Replies

ActionScript 3.0 :: Manually Refresh The Page To See The New Squares

May 17, 2011

So far my code takes hex codes out of tweets containing a certain hashtag, and draws a square of that hex code colour. If someone were to tweet a new set of hexcodes while you were looking at the site, you would have to manually refresh the page to see the new squares.

[Code]....

View 6 Replies







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