Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Dec 2002
    Messaggi
    23

    problema con player: non si ferma!!!!!!!

    ciauz a tutti

    ho un problema un pochetto urgente!

    ho un player che faccio muovere in una stanza.

    Il player si muove al clic del mouse e segue il punto in cui si è cliccato con il mouse.

    FIN QUI FUNZIONA TUTTO!

    IL CODICE:

    onClipEvent(load){
    _x=0;
    _y=0;
    _rotation=0;


    }
    onClipEvent(mouseDown){

    angle = (Math.atan2(_root._ymouse-_y,_root._xmouse-_x)*180/Math.PI)+90;
    _rotation = angle;

    targetx=_root._xmouse;
    targety=_root._ymouse;

    }
    onClipEvent(enterFrame){

    _x+=(targetx-_x)/mySpeed;
    _y+=(targety-_y)/mySpeed;
    }

    HO TROVATO QUESTO CODICE, FRA L'ALTRO CHIARO E SEMPLICE, SU UN TUTORIAL FLAHS.

    IL MIO PROBLEMA:

    il mio problema è che non riesco a far fermare il mio omino quando sbatte nei muri, e farlo in seguito ripartire quando clicco con il mouse.

    DOPO MILLE RICERCHE, ho trovato questo codice...ma funziona solo a metà perchè mi rallenta l'omino vicino al muro, ma dopo qualche tentativo riesce a passare oltre....

    onClipEvent (enterFrame) {
    with (_root.player) {

    // Controls Player Speed
    _root.player.mySpeed = 16;

    // Controls how far the Player bounces off the wall after impact
    myBounce = 16;



    // detect if edges of the player is colliding with the Maze Walls
    if (walls.hitTest(getBounds(_root).xMax, _y, true)) {

    _x -= myBounce;

    }
    if (walls.hitTest(getBounds(_root).xMin, _y, true)) {
    _x += myBounce;

    }
    if (walls.hitTest(_x, getBounds(_root).yMax, true)) {
    _y -= myBounce;

    }
    if (walls.hitTest(_x, getBounds(_root).yMin, true)) {
    _y += myBounce;

    }

    }
    }

    CREDO CHE LA SOLUZIONE SIA RIUSCIRE A FERMARE LA VELOCITà APPANA TOCCA IL MURO E FARLA RIPARTIRE SUBITO DOPO UN NUOVO CLIC DEL MOUSE.

    QUALCUNO PUò AIUTARMI?

    CIAO E GRAZIE IN ANTICIPO

  2. #2
    Utente di HTML.it
    Registrato dal
    Dec 2002
    Messaggi
    23

    nessuno conosce una soluzione?

    help me, nessuno sa aiutarmi?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.