TypeError:game.HexRenderer不是Linux Mint上的构造函数

时间:2014-12-08 13:02:12

标签: javascript linux melonjs

我有:

HexRenderer.js:

/**
 * HexRenderer
 */
game.HexRenderer = game.HexRenderer || {};

game.HexRenderer = me.Renderable.extend({

    init : function() {
        //init logic
    },

    draw : function(context) {
       //draw logic
    },

    update : function() {
        return false;
    }
});

Play.js:

game.PlayScreen = me.ScreenObject.extend({
    /** 
     *  action to perform on state change
     */
    onResetEvent: function() {

        // load a level
        me.levelDirector.loadLevel("hextile");

        // reset the score
        game.data.score = 0;

        // add our HexRenderer to the game world
        //console.log(typeof(game.HexRenderer)); - undefined
        this.hexagonGrid = new game.HexRenderer(); // Error appears here
        me.game.world.addChild(this.hexagonGrid);
    },


    /** 
     *  action to perform when leaving this screen (state change)
     */
    onDestroyEvent: function() {
        // remove the HexRenderer from the game world
        me.game.world.removeChild(this.hexagonGrid);
    }
});

的index.html:

    <!-- melonJS Library -->
    <!-- build:js js/app.min.js -->
    <script type="text/javascript" src="js/lib/melonJS-2.0.0.js"></script>

    <!-- Plugin(s) -->
    <script type="text/javascript" src="js/lib/plugins/debug/debugPanel.js"></script>

    <!-- Game Scripts -->
    <script type="text/javascript" src="js/melon/entities/HexRenderer.js"></script>
    <script type="text/javascript" src="js/melon/Game.js"></script>
    <script type="text/javascript" src="js/melon/Resources.js"></script>

    <script type="text/javascript" src="js/melon/entities/Entities.js"></script>

    <script type="text/javascript" src="js/melon/screens/Title.js"></script>
    <script type="text/javascript" src="js/melon/screens/Play.js"></script>

代码基于melonjs tutorial

在发布时我看到:

  

TypeError:game.HexRenderer不是构造函数

事情是一切在Windows中运行良好,但不适用于Linux Mint (在最后的chrome和firefox版本中尝试过)。

这是一招吗?它的区别在于它与操作系统有何关系?

1 个答案:

答案 0 :(得分:0)

啊,这是一个非常愚蠢的问题。

那离melonjs很远。

在index.html上我有:

<script type="text/javascript" src="js/melon/entities/HexRenderer.js"></script>

但是文件名是hexRenderer.js,我把它改成了HexRenderer.js,一切都开始工作了。 它在Windows上工作的奇怪之处......(见here