现在的位置: 首页 > 综合 > 正文

给合Flash的Socket和AMF3来尝试开发web游戏引擎

2012年01月03日 ⁄ 综合 ⁄ 共 1090字 ⁄ 字号 评论关闭

今天尝试用Socket和AMF3来开发web游戏引擎,用Flash的好处就是因为插件普及率高,无需用户另行安装,所以用Flash来开发丰富的Web游戏成为很好的选择。服务端仍然采用apache mina+AMF3来写Socket服务程序。
演示效果图:
/upload/amf3game.jpg

客户端代码:游戏角色类

  1. /** 
  2. * ... 
  3. * @author Kinglong 
  4. * @version 0.1 
  5. */  
  6.   
  7. package project.test {  
  8.   
  9.     import flash.display.*;  
  10.     import flash.events.*;  
  11.       
  12.     import gs.TweenLite;  
  13.       
  14.     public class GameRole extends Sprite {            
  15.         private var _id:uint;  
  16.         private var tween:TweenLite;  
  17.         public function GameRole(id:uint,self:Boolean=false) {  
  18.             mouseChildren = false;  
  19.             mouseEnabled = false;  
  20.             _id = id;  
  21.             if(self){  
  22.                 this.graphics.beginFill(0xFF0000);                
  23.             }else {  
  24.                 this.graphics.beginFill(0x0000000.6);               
  25.             }  
  26.             this.graphics.drawRoundRect( -10, -1020201010);  
  27.             this.graphics.endFill();  
  28.         }  
  29.           
  30.         public function move(x:Number,y:Number):void {  
  31.             remove();  
  32.             this.x = x;  
  33.             this.y = y;  
  34.         }  
  35.           

抱歉!评论已关闭.