今天尝试用Socket和AMF3来开发web游戏引擎,用Flash的好处就是因为插件普及率高,无需用户另行安装,所以用Flash来开发丰富的Web游戏成为很好的选择。服务端仍然采用apache mina+AMF3来写Socket服务程序。
演示效果图:
客户端代码:游戏角色类
- /**
- * ...
- * @author Kinglong
- * @version 0.1
- */
- package project.test {
- import flash.display.*;
- import flash.events.*;
- import gs.TweenLite;
- public class GameRole extends Sprite {
- private var _id:uint;
- private var tween:TweenLite;
- public function GameRole(id:uint,self:Boolean=false) {
- mouseChildren = false;
- mouseEnabled = false;
- _id = id;
- if(self){
- this.graphics.beginFill(0xFF0000);
- }else {
- this.graphics.beginFill(0x000000, 0.6);
- }
- this.graphics.drawRoundRect( -10, -10, 20, 20, 10, 10);
- this.graphics.endFill();
- }
- public function move(x:Number,y:Number):void {
- remove();
- this.x = x;
- this.y = y;
- }