rifts
04-19-2005, 08:34 PM
im makeing an isometric RPG game but i have a problem with the hitTest already and im not verry far in yet. im currently working on the walking engine. so far i simply have
function moveCharicter() {
if (key.isDown(Key.LEFT)) {
this._x -= 4;
this._y -= 2;
this.gotoAndStop(1);
if (this.hitTest(_root.wall)==true) {
this._x += 4;
this._y += 2;
}
} else {
if (key.isDown(Key.RIGHT)) {
this._x += 4;
this._y += 2;
this.gotoAndStop(2);
if (this.hitTest(_root.wall)==true) {
this._x -= 4;
this._y -= 2;
}
} else {
if (key.isDown(Key.UP)) {
this._x += 4;
this._y -= 2;
this.gotoAndStop(3);
if (this.hitTest(_root.wall)==true) {
this._x -= 4;
this._y += 2;
}
} else {
if (key.isDown(Key.DOWN)) {
this._x -= 4;
this._y += 2;
this.gotoAndStop(4);
if (this.hitTest(_root.wall)==true) {
this._x += 4;
this._y -= 2;
}
}
}
}
}
}
hero.onEnterFrame = moveCharicter
this works fine if i make the wall just a simple block but as its isometric i have made the wall one big black movie clip with an isometric shaped hole in it where the hero should be able to walk in. however i know as it counts the wall movieclip as one big thing so the heros movement was perminantly stuck i was wondering if anyone could help with the actionscript so the hit test was a shape hit test thingy?
function moveCharicter() {
if (key.isDown(Key.LEFT)) {
this._x -= 4;
this._y -= 2;
this.gotoAndStop(1);
if (this.hitTest(_root.wall)==true) {
this._x += 4;
this._y += 2;
}
} else {
if (key.isDown(Key.RIGHT)) {
this._x += 4;
this._y += 2;
this.gotoAndStop(2);
if (this.hitTest(_root.wall)==true) {
this._x -= 4;
this._y -= 2;
}
} else {
if (key.isDown(Key.UP)) {
this._x += 4;
this._y -= 2;
this.gotoAndStop(3);
if (this.hitTest(_root.wall)==true) {
this._x -= 4;
this._y += 2;
}
} else {
if (key.isDown(Key.DOWN)) {
this._x -= 4;
this._y += 2;
this.gotoAndStop(4);
if (this.hitTest(_root.wall)==true) {
this._x += 4;
this._y -= 2;
}
}
}
}
}
}
hero.onEnterFrame = moveCharicter
this works fine if i make the wall just a simple block but as its isometric i have made the wall one big black movie clip with an isometric shaped hole in it where the hero should be able to walk in. however i know as it counts the wall movieclip as one big thing so the heros movement was perminantly stuck i was wondering if anyone could help with the actionscript so the hit test was a shape hit test thingy?