Flax是基于flash的游戏制作工具,所以flash里所见即游戏中所得,场景编辑尤其如此。
请看在线示例
相关代码:
var GameShooters = BaseScene.extend({ onEnter:function() { this._super(); flax.assetsManager.createDisplay(res.shooters, "level1",{parent:this}); } }) var thePropNames = ["HealProp", "MultiProp", "SpeedProp", "ArmorProp"]; var BattleStage = flax.MovieClip.extend({ enemies:null, props:null, onEnter:function() { this._super(); //Init the global bullet container(SpriteBatchNode) flax.BulletCanvas.create(res.shooters, this); this.initElements(); //Set the enemies as the player's target //TODO, there is another method with TileMap to check the bullet collision in Flax this.player.targets = this.enemies; this.player.props = this.props; //Scrolling background // var bg = new flax.ScrollingBG(this.bg); // bg.startYScroll(-50); }, initElements:function() { this.enemies = []; this.props = []; for(var i = 0; i < this.getChildrenCount(); i++){ var child = this.children[i]; if(child instanceof Enemy){ this.enemies.push(child); }else if(thePropNames.indexOf(child.assetID) > -1){ this.props.push(child); } } } ... })
所有示例的Github源码
You must be logged in to post a comment.