【问题标题】:Flixel - FlxWeapon not showing any bulletFlixel - FlxWeapon 没有显示任何子弹
【发布时间】:2012-05-18 05:49:37
【问题描述】:

我尝试使用 FTP FlxWeapon 制作一些子弹(实际上是剑/匕首),但得到了一些意想不到的结果。 这就是我设置 FlxWeapon 的方式:

    sword = new BasicSword("Sword", player, "x", "y");
            sword.makeImageBullet(15, BasicSword.SWORD_GIF,5);
            sword.setBulletDirection(FlxWeapon.BULLET_RIGHT, 400);  
            sword.setPreFireCallback(bulletDirectionCallback);
    //load FlxControl

        if(FlxG.getPlugin(FlxControl) == null){
            FlxG.addPlugin(new FlxControl);
        }
        FlxControl.player1.setFireButton("X", FlxControlHandler.KEYMODE_PRESSED, 100, sword.fire);

        }
/*A callback function, to set a proper direction before we fire the sword*/
        public function bulletDirectionCallback():void{

            if(player.facing == FlxObject.RIGHT){
                sword.setBulletDirection(0, 400); //make the bullet move to the right side with velocity of 400.
            }
            else{ //if player is facing the left direction.
                sword.setBulletDirection(180, 400); //make the bullet move to the left side with the velocity of 400.

            }

        }

重要提示:
BasicSword.as 扩展 Sword.as 和 Sword.as 扩展 FlxWeapon。
BasicSword 和 Sword 中没有什么重要的,实际上 Sword 只有构造函数,而 BasicSword 只有 SWORD_GIF。
- 我认为有效的方法:

1-回调函数。
2-一些方法和变量,例如:setFireRate() 和 bulletsFired。
3-开火按钮(FlxControl.player1.setFireButton)。

-什么不起作用:
1-剑没有出现。

【问题讨论】:

    标签: actionscript-3 flash air flixel


    【解决方案1】:

    我通过在关卡本身加载后放置此代码FlxG.worldBounds.make(0,0,level.width, level.height); 解决了我的错误,因为早些时候(当我遇到错误时)我在创建关卡对象之后放置此代码,但在加载它之前。所以level.widthlevel.height的值是0和0。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-10
      • 1970-01-01
      • 2020-03-24
      • 2014-07-21
      • 2019-02-21
      • 2016-02-19
      相关资源
      最近更新 更多