文件名称:AS3坦克大战源代码 教程
文件大小:242KB
文件格式:RAR
更新时间:2014-06-01 07:51:01
AS3,坦克,大战,编程,教程
纯as3坦克大战源码 MVC框架 备注都写得很清楚, 适合学习 package { import Controllers.BasicController; import Controllers.MonsterController; import flash.display.Sprite; import flash.display.Stage; import flash.geom.Point; import flash.utils.Timer; import Objects.Base; import Objects.GameObject; import Objects.GameSounds; import Objects.Item; import Objects.Monster; import Objects.Player; import Objects.Stone; import Sence.Sence; import Controllers.KeyController; import Objects.ActionObject; import flash.events.TimerEvent; public class Main extends Sprite{ private var mapconfig:Array = [ [0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1], [0, 1, 0, 0, 0, 1, 4, 0, 0, 0, 1, 0], [0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0], [0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3] ]; public function Main() { // constructor code var sence:Sence.MapSence = new Sence.MapSence(stage); sence.setup(mapconfig); addChild(sence); new GameSounds("open.mp3"); var timer:Timer = new Timer(10000); timer.addEventListener(TimerEvent.TIMER, createItem); timer.start(); } private function createItem(e:TimerEvent) { for each(var obj:GameObject in Global.sence.objectArray) { if (obj is Item) obj.die(obj); } //删除当前的物品 /** * 新建物品 */ var p:Point = getRandomPlace(); var item:Item = new Item(new Item_Speed()); item.x = item.width * p.x + Global.INTERVAL; item.y = item.width * p.y + Global.INTERVAL; Global.sence.addObject(item); } private function getRandomPlace():Point { var ry:uint = int(Math.random() * mapconfig.length); var rx:uint = int(Math.random() * mapconfig[0].length); if (mapconfig[ry][rx] == 0) return new Point(rx, ry); return getRandomPlace(); } } }
【文件预览】:
Tank
----Main.as(2KB)
----Tank.as3proj(3KB)
----Main.swf(23KB)
----Main.html(2KB)
----Controllers()
--------MonsterController.as(2KB)
--------BasicController.as(687B)
--------KeyController.as(2KB)
----Sounds()
--------open.mp3(92KB)
--------boom.mp3(18KB)
----MyInterface()
--------IShoot.as(133B)
----Objects()
--------ActionObject.as(3KB)
--------Stone.as(555B)
--------Player.as(1KB)
--------Item.as(1KB)
--------GameSounds.as(944B)
--------GameObject.as(785B)
--------Monster.as(618B)
--------BoomEffect.as(486B)
--------Base.as(540B)
--------FaceObject.as(2KB)
--------BulletObject.as(2KB)
----Sence()
--------MapSence.as(2KB)
--------Sence.as(904B)
----Global.as(572B)
----Main.fla(45KB)
----Tank.rar(100KB)