Ok ^^ bon alors voila mon code pour faire le deplacement :
a = 30;
b = a/2;
speed = 3;
startX = boule._x;
startY = boule._y;
targerX = 0;
targetY = 0;
diagX = 0;
diagY = 0;
_global.direction = "";
_root.boule.onEnterFrame = function() {
move = (targetX || targetY) ? 1 : 0;
if (!move) {
if (Key.isDown(Key.addListener(onMouseDown))) {
if (direction == "UP") {
diagX = 0;
diagY = 0;
startX = boule._x;
startY = boule._y;
targetX = startX+a;
targetY = startY-b;
a = Math.abs(a);
b = -b;
}
if (direction == "DOWN") {
diagX = 0;
diagY = 0;
startX = boule._x;
startY = boule._y;
targetX = startX-a;
targetY = startY+b;
a = -a;
b = Math.abs(b);
}
if (direction == "LEFT") {
diagX = 0;
diagY = 0;
startX = boule._x;
startY = boule._y;
targetX = startX-a;
targetY = startY-b;
a = -a;
b = -b;
}
if (direction == "RIGHT") {
diagX = 0;
diagY = 0;
startX = boule._x;
startY = boule._y;
targetX = startX+a;
targetY = startY+b;
a = Math.abs(a);
b = Math.abs(b);
}
if (direction == "UPRIGHT") {
diagX = 0;
diagY = 1;
startX = boule._x;
startY = boule._y;
targetX = startX+(a*2);
targetY = startY;
a = Math.abs(a);
b = Math.abs(b);
}
if (direction == "DOWNLEFT") {
diagX = 0;
diagY = 1;
startX = boule._x;
startY = boule._y;
targetX = startX-(a*2);
targetY = startY;
a = -a;
b = Math.abs(b);
}
if (direction == "UPLEFT") {
diagX = 1;
diagY = 0;
startX = boule._x;
startY = boule._y;
targetX = startX;
targetY = startY-(b*2);
a = Math.abs(a);
b = -b;
}
if (direction == "DOWNRIGHT") {
diagX = 1;
diagY = 0;
startX = boule._x;
startY = boule._y;
targetX = startX;
targetY = startY+(b*2);
a = Math.abs(a);
b = Math.abs(b);
}
}
}
if (move) {
if (Math.round(this._x) != Math.round(targetX) && !d iagX) {
this._x += a/speed;
}else{
targetX = 0;
a = Math.abs(a);
}
if (Math.round(this._y) != Math.round(targetY) && !d iagY) {
this._y += b/speed;
}else{
targetY = 0;
b = Math.abs(b);
}
}
};
_root.direct_mc.onEnterFrame = function() {
angle = Math.round(direct_mc._rotation);
this._x = _root.boule._x;
this._y = _root.boule._y;
this._rotation = Math.atan2(_root._ymouse-this._y, _root._xmouse-this._x)/(Math.PI/180);
if (angle<=-17 && angle>=-49) {
direction = "UP";
} else if (angle<=-50 && angle>=-138) {
direction = "UPLEFT";
} else if (angle<=-139 && angle>=-171) {
direction = "LEFT";
} else if (angle<=-172 && angle>=-180) {
direction = "DOWNLEFT";
} else if (angle<=180 && angle>=159) {
direction = "DOWNLEFT";
} else if (angle<=158 && angle>=117) {
direction = "DOWN";
} else if (angle<=116 && angle>=53) {
direction = "DOWNRIGHT";
} else if (angle<=52 && angle>=13) {
direction = "RIGHT";
} else if (angle<=12 && angle>=-16) {
direction = "UPRIGHT";
} else {
direction = "";
}
};
Bon alors apres cela j´aurais peut etre trouver un code me permettant de gerer les collisions :
if (!_root.murs.hitTest( this._x+X,this._y+Y,true))
{
this._x+=X;
this._y+=Y;
Y=0;
X=0;
}
Sachant que l´instance de mon clip se nomme mur, ou est ce que je dois placer ce code ou sinon quel code mettre.