Visualizzazione dei risultati da 1 a 4 su 4

Discussione: funzione hitTest

  1. #1

    funzione hitTest

    salve a tutti, ho un problema!! Faccio muovere un oggetto tramite i tasti della tastiera con questo script, adesso vorrei che alla presenza di certi altri oggetti si fermasse. In pratica devo far correre un pupetto e devo far in modo che quando incontra un murop si fermi. Come faccio? THX
    Overhead the albatross hangs/motionless upon the air/And deep beneath the rolling waves/in labyrinths of coral caves/The echo of a distant time/Comes willowing across the sand/And everything is green and submarine

  2. #2
    ops.. ecco lo script:
    onClipEvent (load) {
    speed = 10;
    }
    onClipEvent (enterFrame) {
    if (Key.isDown(Key.LEFT) && !Key.isDown(Key.RIGHT)) {
    _x -= speed;
    _rotation = 270;
    }
    if (Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT)) {
    _x += speed;
    _rotation = 90;
    }
    if (Key.isDown(Key.UP) && !Key.isDown(Key.DOWN)) {
    _y -= speed;
    _rotation = 0;
    }
    if (Key.isDown(Key.DOWN) && !Key.isDown(Key.UP)) {
    _y += speed;
    _rotation = 180;
    }
    if (Key.isDown(Key.LEFT) && Key.isDown(Key.UP) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.DOWN)) {
    _rotation = 315;
    }
    if (Key.isDown(Key.RIGHT) && Key.isDown(Key.UP) && !Key.isDown(Key.LEFT) && !Key.isDown(Key.DOWN)) {
    _rotation = 45;
    }
    if (Key.isDown(Key.LEFT) && Key.isDown(Key.DOWN) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.UP)) {
    _rotation = 225;
    }
    if (Key.isDown(Key.RIGHT) && Key.isDown(Key.DOWN) && !Key.isDown(Key.LEFT) && !Key.isDown(Key.UP)) {
    _rotation = 135;
    }
    Overhead the albatross hangs/motionless upon the air/And deep beneath the rolling waves/in labyrinths of coral caves/The echo of a distant time/Comes willowing across the sand/And everything is green and submarine

  3. #3
    UP!!!!!!!!!!!!!!!!!!
    Overhead the albatross hangs/motionless upon the air/And deep beneath the rolling waves/in labyrinths of coral caves/The echo of a distant time/Comes willowing across the sand/And everything is green and submarine

  4. #4
    Non ne so poi molto neanchio, ma prova questo.
    Metti un movie nella parte bassa dello schermo e dagli nome istanza "muro" e poi sul tuo movie che si muove dagli questo:
    onClipEvent (load) {
    speed = 10;
    }
    onClipEvent (enterFrame) {
    if (Key.isDown(Key.LEFT) && !Key.isDown(Key.RIGHT)) {
    speed = 10;
    _x -= speed;
    _rotation = 270;
    }
    if (Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT)) {
    speed = 10;
    _x += speed;
    _rotation = 90;
    }
    if (Key.isDown(Key.UP) && !Key.isDown(Key.DOWN)) {
    speed = 10;
    _y -= speed;
    _rotation = 0;
    }
    if (this.hitTest (_root.muro)) {
    speed = false;
    } else if (Key.isDown(Key.DOWN) && !Key.isDown(Key.UP)) {
    speed = 10;
    _y += speed;
    _rotation = 180;
    }
    if (Key.isDown(Key.LEFT) && Key.isDown(Key.UP) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.DOWN)) {
    _rotation = 315;
    }
    if (Key.isDown(Key.RIGHT) && Key.isDown(Key.UP) && !Key.isDown(Key.LEFT) && !Key.isDown(Key.DOWN)) {
    _rotation = 45;
    }
    if (Key.isDown(Key.LEFT) && Key.isDown(Key.DOWN) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.UP)) {
    _rotation = 225;
    }
    if (Key.isDown(Key.RIGHT) && Key.isDown(Key.DOWN) && !Key.isDown(Key.LEFT) && !Key.isDown(Key.UP)) {
    _rotation = 135;
    }
    }
    Questo funziona solo per il "muro" cioè quando lo tocca blocca "speed", naturalmente se il muro non lo devi mettere in basso devi cambiare le azioni.

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.