0

I've coded a little game, but now I realized that I should include all the actions to frame on layer called "actions". This far I've written my code to movieclip. Any help on transforming this to frame?

onClipEvent (load) {
    yspeed = 0;
    lastx = 0;
    gravity = 0.2;
    speed = 5;
}

onClipEvent (enterFrame) {
    yspeed += gravity;

    if (_root.flake.hitTest(_root.cloud._x, _root.cloud._y, true)) {
        yspeed = -9;
    }

    _root.cloud._x += (_root._xmouse-lastx+10)/speed;
    lastx = _root.cloud._x;
    _root.cloud._y += yspeed;

    function asd() {
        this._x += 2;
    }

    _root.flake.duplicateMovieClip("flake1",1,{_x:50, _y:350});
    _root.flake1.onEnterFrame = asd;

}

Hope you understood. So no those onClipEvents, just a frame where I write all actions.

Also, I'm a beginner so any advice could be nice!

Thanks in advance, Martti Laine

4

1 回答 1

1

我不完全理解你的问题。

你想把解码代码简单地放在整个场景的第一帧中,还是放在影片剪辑的第一帧中。

如果它在场景的第一帧上,那么您的代码将同步:

    if(counter == undefined){
        yspeed = 0;
        lastx = 0;
        gravity = 0.2;
        speed = 5;
        counter = "def";
    }


    yspeed += gravity;

    if (_root.flake.hitTest(_root.cloud._x, _root.cloud._y, true)) {
        yspeed = -9;
    }

    _root.cloud._x += (_root._xmouse-lastx+10)/speed;
    lastx = _root.cloud._x;
    _root.cloud._y += yspeed;

    function asd() {
        this._x += 2;
    }

    _root.flake.duplicateMovieClip("flake1",1,{_x:50, _y:350});
    _root.flake1.onEnterFrame = asd;
于 2010-02-21T12:28:21.493 回答