0

ボタンをクリックして移動できる大きな静止画のようなものを作りたいと思っています。「跳ねる」効果があります。特定の位置に移動するボタンは問題ありませんが、特定の制限内で自由に移動できる追加のボタンはさらに優れています.

私は Actionscript 1.0 にそのスクリプトを持っています。何年も前にどこかで見つけましたが、3.0 用に更新する方法がわかりません (同様の効果を説明するチュートリアルがあるかどうかもわかりません)

可動ムービークリップのスクリプト:

onClipEvent (load) {
    moving = 0;
    x = 0;
    rebote = 0;
    section_actual = 1;
    section_new = 1;
    friction = 0.9;
}
onClipEvent (enterFrame) {
    if (moving == 1)
    {
        if (cambio == 1)
        {
            if (section_actual-section_new<0)
            {
                accel = -2;
            }
            else
            {
                accel = 2;
            }
        }
        cambio = 0;
        section_actual = section_new;
        if (accel == -2)
        {
            if (_x+xvel<=x)
            {
                xvel = -xvel;
                _x = x;
                xvel += accel;
                xvel *= friction;
                rebote = 1;
            }
            else
            {
                _x += xvel;
                xvel += accel;
                xvel *= friction;
            }
        }
        if (accel == 2)
        {
            if (_x+xvel>=x)
            {
                xvel = -xvel;
                _x = x;
                xvel += accel;
                xvel *= friction;
                rebote = 1;
            }
            else
            {
                _x += xvel;
                xvel += accel;
                xvel *= friction;
            }
        }
    }
}

1 つのボタンのスクリプト:

on (release) {
    tellTarget ("../")
    {
        moving = 1;
        x = -335;
        rebote = 0;
        section_new = 2;
        cambio = 1;
    }
}

問題とは関係ありませんが、まだ必要なので、ボタンの機能を更新する必要があります。

on (release) {
    _root.gotoAndStop("TT");
}
4

1 に答える 1

2

1行のコードでアニメーションチェーン全体を処理できるライブラリパッケージ全体があります。

トゥイナー

TweenLite

于 2010-09-24T18:46:27.977 に答える