Isometric View

Hello everyone. Im new here at the forums, but have been working with Flash for about a year now. Im currently making my first game, and I have stumbled upon a problem already.

My game will be drawn in an isometric view, so movement will have to be limited to the isometric directions. And theres the problem. First of all, Ive tried to make the character move on isometric plains.

The X and Y movement coordinates are as follows:

[AS]onClipEvent(enterFrame){
with (_root.area.square)
//
// keyboard controls
if (Key.isDown(Key.DOWN)) {
_x += 0.95, _y += 0.55;
}
if (Key.isDown(Key.UP)) {
_x -= 0.95, _y -= 0.55;
}
if (Key.isDown(Key.LEFT)) {
_y += 0.55, _x -= 0.95;
}
if (Key.isDown(Key.RIGHT)) {
_y -= 0.55, _x += 0.95;
}
if (Key.isDown(Key.RIGHT)&&Key.isDown(Key.DOWN)) {
_x += -0.95, _y += -0.55;
}
if (Key.isDown(Key.RIGHT)&&Key.isDown(Key.UP)) {
_x += +0.95, _y += +0.55;
}
if (Key.isDown(Key.LEFT)&&Key.isDown(Key.DOWN)) {
_y += -0.55, _x -= +0.95;
}
if (Key.isDown(Key.LEFT)&&Key.isDown(Key.UP)) {
_y += +0.55, _x -= -0.95;
}
}[/AS]

But after a while, the character that is moving moves a little bit “off” the isometric line. (The rest of the code there is just to hinder movement beyond straight lines).

Now, another problem also arose. The hitTest is not working properly. Since lines are isometricly drawn, I have to check for a hitTest according to the graphics, not the bounds. Here is what that code looks like:

[AS]onClipEvent (enterFrame) {
checkHit = _root.area.edge.hitTest(_root.area.square, true);
[/AS]

Now, I feel that the hitTest there is wrong (it seems as though Flash thinks that the “true” parameter is for the _y bounds… But I can`t figure out how to fix it. :trout:
Anyhow, this script checks if the character hits a box in isometric. (30-32.5 degrees, I think it was).

I hope you will take some time to help me :slight_smile: I would be very grateful!!