Actionscript 3 AS3拖放到单个对象

Actionscript 3 AS3拖放到单个对象,actionscript-3,Actionscript 3,(我的英语不好,所以请友善点:)) 我正在做一个简单的flash游戏,其中一个大圆圈的边上有8个小圆圈。我想把这8个小圆一个一个地拖到大圆上 基本上是一个盘子和他们的食物。把他们的食物拖到盘子里。我希望这能给你一个更好的主意。 我也用同样的方法去看它,但却得不到我想要的 请告诉我剧本或方法 如果有任何链接或图坦卡蒙,请让我知道我会非常感激 谢谢 Kunal(Web-Designer)此代码经过测试并正常工作。类DummyCircle在实例化时只在其图形对象上绘制一个中心圆 private var

(我的英语不好,所以请友善点:))

我正在做一个简单的flash游戏,其中一个大圆圈的边上有8个小圆圈。我想把这8个小圆一个一个地拖到大圆上

基本上是一个盘子和他们的食物。把他们的食物拖到盘子里。我希望这能给你一个更好的主意。 我也用同样的方法去看它,但却得不到我想要的

请告诉我剧本或方法

如果有任何链接或图坦卡蒙,请让我知道我会非常感激

谢谢


Kunal(Web-Designer)

此代码经过测试并正常工作。类DummyCircle在实例化时只在其图形对象上绘制一个中心圆

private var plate:Sprite;
private var stage:Stage;

public function execute(stage:Stage):void 
{
    this.stage = stage;
    // number of pieces around the centered plate
    const numPieces:int = 8;
    const plateRadius:int = 50;
    plate = new DummyCircle(plateRadius);
    // center plate on the stage
    plate.x = stage.stageWidth / 2;
    plate.y = stage.stageHeight / 2;
    stage.addChild(plate);
    // for each piece to be created
    for (var i:int = 0; i < numPieces; i++) {
        // instantiate the appropriate sprite, here with a radius argument
        var piece:Sprite = new DummyCircle(plateRadius / numPieces);
        // add event listener for dragging
        piece.addEventListener(MouseEvent.MOUSE_DOWN, mouseListener);
        piece.addEventListener(MouseEvent.MOUSE_UP, mouseListener);
        // pieces are in the top left corner of the stage, plate is centered
        piece.x = 0;
        piece.y = 0;
        // a transformation matrix is used for positioning the pieces
        // get the current matrix
        var pieceMatrix:Matrix = piece.transform.matrix;
        // move a bit more than the plate radius on the y axis
        pieceMatrix.translate(0, -plateRadius * 1.5);
        // rotate around the origin
        pieceMatrix.rotate(i * (2 * Math.PI / numPieces));
        // move again, this time to our plate
        pieceMatrix.translate(plate.x, plate.y);
        // apply the matrix
        piece.transform.matrix = pieceMatrix;
        stage.addChild(piece);
    }
}

private function mouseListener(e:MouseEvent):void 
{
    if (e.target is Sprite) {
        var target:Sprite = e.target as Sprite;
        if (e.type == MouseEvent.MOUSE_UP) {
            target.stopDrag();
            if (target.hitTestObject(plate)) {
                stage.removeChild(target);
            }
        }
        else if (e.type == MouseEvent.MOUSE_DOWN) {
            target.startDrag();
        }
    }
}
私有var板:雪碧;
私有var阶段:阶段;
公共功能执行(阶段:阶段):无效
{
这个阶段=阶段;
//中心板周围的工件数量
常数numPieces:int=8;
常数板半径:int=50;
板材=新的Dummy圆(板材半径);
//舞台中央板
板x=第级台阶宽度/2;
板y=阶段高度/2;
阶段。添加儿童(板);
//对于要创建的每个工件
对于(变量i:int=0;i