0

所以我做了一个游戏。有一个人和一把剑。你可以拖动剑。我有个主意:

如果我拖着剑,我把它移到男人身上,那么男人就会把它捡起来。如果我不把它移到人身上,那么剑就会瞬移回第一个位置。

在此处输入图像描述

我该如何编程?我试过这个,但不起作用:

on (press) {
startDrag(this);
}
on (release) {
stopDrag();
if (_root.vcam.inventory.inventory_items.sword1._y == 90 - 270 & _root.vcam.inventory.inventory_items.sword1._x == -430 - -350)
{
_root.man.sword._visible = true;
}
else
{
    _root.vcam.inventory.inventory_items.sword1._x = 0;
    _root.vcam.inventory.inventory_items.sword1._y = 0;
}
}
4

1 回答 1

0

这是一个例子:

关于剑的短片动作:

onClipEvent (load) {
    // save original position
    var origine = {x:_x,y:_y}       

    function onPress() {
        this.startDrag(false);
        this.onEnterFrame = function() {
            // check if the sword hits the man
            if (this.hitTest(_root.man) ) {
                this.stopDrag();
                delete this.onEnterFrame;
                // make the "sword" clip of the man visible
                _root.man.sword._visible = true; 
                // hide this
                _visible = false; 
            }
        }
    }

    // releasing not on the man
    function onRelease() {
        this.stopDrag();
        this._x = origine.x;
        this._y = origine.y;
    }
}
于 2013-10-25T22:21:12.487 回答