actionScripter1
12-09-2008, 09:41 AM
Hi, I am trying to do a tetris with Flex, using ActionScript 3 and I am having some problems with the collisions of the blocks... Collisions are working, but blocks collide on their corners, which is a problem and I do not know how to solve this... Any ideas?
Also, I am trying to get the global coordinates of my blocks, to solve that problem, but for some reason I never get the global coordinates... This is what I am doing to get them (each block is inside an array of Sprites). The array is named squares. The example below shows how I try to get the global x and y points for a T-block:
var pt1:Point = new Point( (squares[counter-3].x), (squares[counter-3].y));
pt1 = squares[counter-3].localToGlobal(pt1);
var pt2:Point = new Point( (squares[counter-2].x) , (squares[counter-2].y));
pt2 = squares[counter-2].localToGlobal(pt2);
var pt3:Point = new Point(squares[counter-1].x, squares[counter-1].y);
pt3 = squares[counter-1].localToGlobal(pt3);
var pt4:Point = new Point(squares[counter].x, squares[counter].y);
pt4 = squares[counter].localToGlobal(pt4);
When I trace that, I get the same positions for every square, while in fact they are definitely in different positions in the stage...
Any ideas?
Thanks!
Also, I am trying to get the global coordinates of my blocks, to solve that problem, but for some reason I never get the global coordinates... This is what I am doing to get them (each block is inside an array of Sprites). The array is named squares. The example below shows how I try to get the global x and y points for a T-block:
var pt1:Point = new Point( (squares[counter-3].x), (squares[counter-3].y));
pt1 = squares[counter-3].localToGlobal(pt1);
var pt2:Point = new Point( (squares[counter-2].x) , (squares[counter-2].y));
pt2 = squares[counter-2].localToGlobal(pt2);
var pt3:Point = new Point(squares[counter-1].x, squares[counter-1].y);
pt3 = squares[counter-1].localToGlobal(pt3);
var pt4:Point = new Point(squares[counter].x, squares[counter].y);
pt4 = squares[counter].localToGlobal(pt4);
When I trace that, I get the same positions for every square, while in fact they are definitely in different positions in the stage...
Any ideas?
Thanks!