在Flash cc中,我想知道如何制作拖放游戏。但是根据你的拖动,物体会旋转,所以重力会影响它。例如,如果您用拇指和索引在底部拿起一张纸,纸张将会旋转,因此您将其保持在顶部。如何在flash中重新创建它?
到目前为止,这是我的代码...(我是闪光灯的新手,所以请慷慨解答)
var drag:Number = 1;
var BlockAppear = new MovieClip;
gotoAndStop(1, "Minigame-Block");
HeartBear.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_4);
function fl_ClickToDrag_4(event:MouseEvent):void
{
HeartBear.startDrag()
gravity = 0
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_4);
function fl_ReleaseToDrop_4(event:MouseEvent):void
{
HeartBear.stopDrag();
gravity = 0.9
}
{
var gravity = 0.9;
var floor = 241.3;
HeartBear.y = 710.9;
HeartBear.speedY = 0;
HeartBear.impulsion = 10;
stage.addEventListener(Event.ENTER_FRAME, enterframe);
function enterframe(e:Event) {
HeartBear.speedY += gravity;
HeartBear.y += HeartBear.speedY;
if(HeartBear.y > floor) {
HeartBear.speedY = 0;
HeartBear.y = floor
}
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, space);
function space(e:KeyboardEvent) {
if(e.keyCode == Keyboard.SPACE) {
HeartBear.speedY = -HeartBear.impulsion
}
}
}
Shopclicker.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_3);
function fl_ClickToGoToScene_3(event:MouseEvent):void
{
MovieClip(this.root).gotoAndStop(1, "Shop");
}