函数没有过程体是什么意思。
package{importflash.display.MovieClip;importflash.events.KeyboardEvent;importflash.ui...
package
{
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.events.Event;
public class main_snake extends MovieClip
{
var sx:int;
var sy:int;
public function main_snake();
{
init();
}
function init():void;
{
sx = 0;
sy = 0;
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
function onKeyDown(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.LEFT)
{
sx = -5;
}
else if (event.keyCode == Keyboard.RIGHT)
{
sx = 5;
}
else if (event.keyCode == Keyboard.UP)
{
sy = -5;
}
else if (event.keyCode == Keyboard.DOWN)
{
sy = 5;
}
}
function onKeyUp(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.LEFT || event.keyCode == Keyboard.RIGHT)
{
vx = 0;
}
else if (event.keyCode == Keyboard.DOWN || event.keyCode == Keyboard.UP)
{
vy = 0;
}
}
function onEnterFrame(event:Event):void
{
snake.x += sx;
snake.y += sy;
}
}
} 展开
{
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.events.Event;
public class main_snake extends MovieClip
{
var sx:int;
var sy:int;
public function main_snake();
{
init();
}
function init():void;
{
sx = 0;
sy = 0;
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
function onKeyDown(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.LEFT)
{
sx = -5;
}
else if (event.keyCode == Keyboard.RIGHT)
{
sx = 5;
}
else if (event.keyCode == Keyboard.UP)
{
sy = -5;
}
else if (event.keyCode == Keyboard.DOWN)
{
sy = 5;
}
}
function onKeyUp(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.LEFT || event.keyCode == Keyboard.RIGHT)
{
vx = 0;
}
else if (event.keyCode == Keyboard.DOWN || event.keyCode == Keyboard.UP)
{
vy = 0;
}
}
function onEnterFrame(event:Event):void
{
snake.x += sx;
snake.y += sy;
}
}
} 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询