都好几个月了,今天偶然看到.留着也没心思做下去了.基本的功能有了,比如射击后的cooldown时间之类的.有兴趣的可以接着做.地图没有做.临时用的浪子写的那个东东.
点这里下载
也可以先点试玩一下
操作方法:
wasd是方向,鼠标左键是开火,类似CS
下面贴一个hero的as以供提前参考
class hero extends animal{
var colddown:Boolean;
var colddownTime:Number;
var bullets:Number;
var tObject:Object;
var drawmap:Boolean;
//初始化
function hero(){
colddown=true;
colddownTime=1;
bullets=1;
life=100;
speed=3;
aVisible=true;
drawmap=false;
onEnterFrame=function(){
this.gun._rotation=xy2angle(this,_root.game._xmouse,_root.game._ymouse);
movehero();
//myHitest();
}
}
//秽动
function trueMove(dir:Number,xinc:Number,yinc:Number){
if (dir!=0){
this.gotoAndStop(dir+1);
this._x+=speed*xinc
this._y+=speed*yinc
}else this.gotoAndStop(1);
}
function movehero(){
if (Key.isDown(1))fire();
var movedir=0,xinc=0,yinc=0
if (Key.isDown(65)) {
if (Key.isDown(87)) {movedir=2,xinc=-0.707,yinc=-0.707}
else if (Key.isDown(83)) {movedir=8,xinc=-0.707,yinc=0.707}
else {movedir=1,xinc=-1,yinc=0}
}else if(Key.isDown(68)){
if (Key.isDown(87)) {movedir=4,xinc=0.707,yinc=-0.707}
else if (Key.isDown(83)) {movedir=6,xinc=0.707,yinc=0.707}
else {movedir=5,xinc=1,yinc=0}
}else if(Key.isDown(87)) {movedir=3,xinc=0,yinc=-1}
else if(Key.isDown(83)) {movedir=7,xinc=0,yinc=1}
else movedir=0,xinc=0,yinc=0;
trueMove(movedir,xinc,yinc);
}
//开火
function fire(){
if (colddown){
var bbullet=_root.game.attachMovie("bullet","bullet"+bullets,1500+bullets);
bbullet._x=_x;
bbullet._y=_y;
bbullet._rotation=xy2angle(this,_root.game._xmouse,_root.game._ymouse);
colddown=false;
var checkCold=setInterval(checkColddown,colddownTime*1000,this);
}
function checkColddown(tt){
tt.colddown=true;
clearInterval(checkCold);
}
}
//碰撞检测
function myHitest(){
}
}
点这里下载
也可以先点试玩一下
操作方法:
wasd是方向,鼠标左键是开火,类似CS
下面贴一个hero的as以供提前参考
class hero extends animal{
var colddown:Boolean;
var colddownTime:Number;
var bullets:Number;
var tObject:Object;
var drawmap:Boolean;
//初始化
function hero(){
colddown=true;
colddownTime=1;
bullets=1;
life=100;
speed=3;
aVisible=true;
drawmap=false;
onEnterFrame=function(){
this.gun._rotation=xy2angle(this,_root.game._xmouse,_root.game._ymouse);
movehero();
//myHitest();
}
}
//秽动
function trueMove(dir:Number,xinc:Number,yinc:Number){
if (dir!=0){
this.gotoAndStop(dir+1);
this._x+=speed*xinc
this._y+=speed*yinc
}else this.gotoAndStop(1);
}
function movehero(){
if (Key.isDown(1))fire();
var movedir=0,xinc=0,yinc=0
if (Key.isDown(65)) {
if (Key.isDown(87)) {movedir=2,xinc=-0.707,yinc=-0.707}
else if (Key.isDown(83)) {movedir=8,xinc=-0.707,yinc=0.707}
else {movedir=1,xinc=-1,yinc=0}
}else if(Key.isDown(68)){
if (Key.isDown(87)) {movedir=4,xinc=0.707,yinc=-0.707}
else if (Key.isDown(83)) {movedir=6,xinc=0.707,yinc=0.707}
else {movedir=5,xinc=1,yinc=0}
}else if(Key.isDown(87)) {movedir=3,xinc=0,yinc=-1}
else if(Key.isDown(83)) {movedir=7,xinc=0,yinc=1}
else movedir=0,xinc=0,yinc=0;
trueMove(movedir,xinc,yinc);
}
//开火
function fire(){
if (colddown){
var bbullet=_root.game.attachMovie("bullet","bullet"+bullets,1500+bullets);
bbullet._x=_x;
bbullet._y=_y;
bbullet._rotation=xy2angle(this,_root.game._xmouse,_root.game._ymouse);
colddown=false;
var checkCold=setInterval(checkColddown,colddownTime*1000,this);
}
function checkColddown(tt){
tt.colddown=true;
clearInterval(checkCold);
}
}
//碰撞检测
function myHitest(){
}
}
回复Comments
作者:
{commentrecontent}