rexrainbow / phaser3-rex-notes

Notes of phaser3 engine
MIT License
1.21k stars 261 forks source link

rexInputTextPlugin- Super expression must either be null or a function #191

Closed sky-is-winning closed 3 years ago

sky-is-winning commented 3 years ago

Rex Input Text Plugin is installed like this

<script type="text/javascript" src="assets/components/rexinputtextplugin.min.js"></script>

var config = {  
 type: Phaser.AUTO, 
    dom: {createContainer: true},
      plugins: {
        scene: [{
          key: 'rexInputText
          plugin: rexinputtextplugin,
          mapping: 'rexInputText'
}]}};

But when trying to load my game, I get hit with 'Super expression must either be null or a function' This doesn't happen when the plugin is disabled I'm not trying to load anything with the plugin, just it being loaded is causing this.

rexrainbow commented 3 years ago

You might try to load pluigin in preload stage, like this demo, line 13

sky-is-winning commented 3 years ago

Using the exact code from that demo, I get the same thing.

    function preload() {    
        this.load.pack("pack", "assets/asset-pack.json");
        this.load.plugin('rexinputtextplugin', 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/dist/rexinputtextplugin.min.js', true);   
    }
rexrainbow commented 3 years ago

No idea sorry, I could not reproduce this issue in my environment. Could you list more detail about browser and provide a runnable code?

sky-is-winning commented 3 years ago

I'm using Microsoft Edge (Chromium) And here's the code

<!DOCTYPE html>
<html>
<head>
    <script src="/lib/phaser.js"></script>
</head>
<body>

<script>
    var config = {  
        type: Phaser.AUTO,  
        dom: {
            createContainer: true
        },
        width: 1520,    
        height: 960,    
        scene: {    
            preload: preload,   
            create: create,
        }
    };  

    var game = new Phaser.Game(config); 

    function preload() {    
        this.load.pack("pack", "assets/asset-pack.json");
        this.load.plugin('rexinputtextplugin', 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/dist/rexinputtextplugin.min.js', true);   
    }

    function create() {
        this.add.image(760, 480, "main-bg");
        var loading = this.add.sprite(760, 480, 'loading');
        loading.play("loading")
        }
    </script>
    </body>
    </html>
sky-is-winning commented 3 years ago

Okay, weirdly I've now stopped getting that error (with the exact same code) but now when I try to put input text on the screen with

var inputText = this.add.rexInputText(760, 480, 100, 20, {
  type: 'textarea',
  text: 'hello world',
  fontSize: '12px',
  background: '#ffffff'
})

absolutely nothing happens

rexrainbow commented 3 years ago

Please check 'parent' parameter, (that demo, line 53), that value will equal to the div of phaser3 game engine. See the 'HTML' part of that demo.