CONNEXION
  • RetourJeux
    • Sorties
    • Hit Parade
    • Les + populaires
    • Les + attendus
    • Soluces
    • Tous les Jeux
    • Gaming
  • RetourActu Gaming
    • News
    • Astuces
    • Tests
    • Previews
    • Toute l'actu gaming
  • RetourBons plans
    • Bons plans
    • Bons plans Smartphone
    • Bons plans Hardware
    • Bons plans Image et Son
    • Bons plans Amazon
    • Bons plans Cdiscount
    • Bons plans Decathlon
    • Bons plans Fnac
    • Tous les Bons plans
  • RetourJVTech
    • Actus High-Tech
    • Intelligence Artificielle
    • Smartphones
    • Mobilité urbaine
    • Hardware
    • Image et son
    • Tutoriels
    • Tests produits High-Tech
    • Guides d'achat High-Tech
    • JVTech
  • RetourCulture
    • Actus Culture
    • Culture
  • RetourVidéos
    • A la une
    • Gaming Live
    • Vidéos Tests
    • Vidéos Previews
    • Gameplay
    • Trailers
    • Chroniques
    • Replay Web TV
    • Toutes les vidéos
  • RetourForums
    • Hardware PC
    • PS5
    • Switch 2
    • Xbox Series
    • Switch
    • Pokemon pocket
    • FC 25 Ultimate Team
    • League of Legends
    • Tous les Forums
  • PC
  • PS5
  • Xbox Series
  • Switch 2
  • PS4
  • One
  • Switch
  • iOS
  • Android
  • MMO
  • RPG
  • FPS
En ce moment Genshin Impact Valhalla Breath of the wild Animal Crossing GTA 5 Red dead 2
Liste des sujets

Collisions en FLASH

yamadru
yamadru
Niveau 5
05 mars 2006 à 16:45:18

Salut a tous,
voila je suis en train de réaliser un RPG en flash qui est diriger grace a la souris, pour le moment j´ai fait la gestion du mouvement, la connexion et l´interface mais je n´arrive pas a faire ola gestion des colisions, j´ai cree un clip que j´ai nommé mur, il encadre toute la surface de jeu et j´aimerais que lorsque le clip personnage entre en contact avec le clip mur cela bloc le mouvement et le joueur ne puisse pas aller plus loin, alors j´aimerais savoir si quelqu´un avait un code action script qui permette de realiser cette action, je vous remerci d´avance.

godrik
godrik
Niveau 30
05 mars 2006 à 17:56:30

j´ai bien peur qu´il te faille l´écrire... C´est si difficile que ca ? réfléchis un peu, ce n´est pas tres dur...

yamadru
yamadru
Niveau 5
05 mars 2006 à 19:26:22

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.

Sous forums
  • Aide à l'achat Mac
  • Création de Jeux
  • Linux
  • Création de sites web
  • Programmation
  • Internet
  • Steam Deck
  • Macintosh
  • Hardware
La vidéo du moment