Andrio
January 18, 2020, 12:21pm
1
Hello !
I’m very needed to install this plugin for Round Rectangle object : https://rexrainbow.github.io/phaser3-rex-notes/docs/site/shape-roundrectangle/
But all my attempts were unsuccessful.
What i did :
I wrote in config everything same as in example.
Here is plugin:
import Factory from './gameobjects/shape/roundrectangle/Factory.js';
import Creator from './gameobjects/shape/roundrectangle/Creator.js';
import RoundRectangle from './gameobjects/shape/roundrectangle/RoundRectangle.js';
import SetValue from './utils/object/SetValue.js';
class RoundRectanglePlugin extends Phaser.Plugins.BasePlugin {
constructor(pluginManager) {
super(pluginManager);
// Register our new Game Object type
pluginManager.registerGameObject('rexRoundRectangle', Factory, Creator);
}
start() {
var eventEmitter = this.game.events;
eventEmitter.once('destroy', this.destroy, this);
}
}
This file has been truncated. show original
I downloaded libraries and set up all paths from github , as here :
import Factory from ‘./gameobjects/shape/roundrectangle/Factory.js’;
import Creator from ‘./gameobjects/shape/roundrectangle/Creator.js’;
import RoundRectangle from ‘./gameobjects/shape/roundrectangle/RoundRectangle.js’;
import SetValue from ‘./utils/object/SetValue.js’;
In my index.html i wrote this :
I’v got this mistake:
Trying to solve this mistake, I downloaded from github and uploaded this file to my server :
… utils/math/DegToRad.js but it didn’t help
May be somewhere have examples how to install plugins from github ?
Please help me ! I desperately need this plugin !
1 Like
Are you using webpack? @Andrio
Copy the minified version to a folder on your project. Here is the link: https://github.com/rexrainbow/phaser3-rex-notes/blob/master/dist/rexroundrectangleplugin.min.js
Import that file to your config file. Then add it to the config:
Import RoundRectanglePlugin from 'rexroundrectangleplugin.min'
var config = {
// ...
plugins: {
global: [{
key: 'rexRoundRectanglePlugin',
plugin: RoundRectanglePlugin,
start: true
},
// ...
]
}
// ...
};
var game = new Phaser.Game(config);
Andrio
January 18, 2020, 3:04pm
4
piratepablo
Thanks, i did what you said but have error:
“Uncaught SyntaxError: Cannot use import statement outside a module”
I think i need write it like this :
< script src="phaser.min.js"></script>
< script src="rexroundrectangleplugin.min.js"></script>
After this, I have diffrenet error :
I even installed “phaser3-rex-plugins” with this command “npm install phaser3-rex-plugins”
and then wrote direct path to file and have same error .
Nemesis
No , I doesn’t use webpack.
Andrio
January 18, 2020, 4:38pm
5
<script type="module">
import { RoundRectanglePlugin } from "/phaser3-rex-plugins/plugins/roundrectangle-plugin.js";
console.log ("RoundRectanglePlugin == " , RoundRectanglePlugin )
</script>
This script gives such error :
Uncaught SyntaxError: The requested module ‘…/…/…/utils/math/DegToRad.js’ does not provide an export named ‘default’
Same error with :
import { RoundRectanglePlugin } from “/rexroundrectangleplugin.min.js”;
I think that you might use the plugin in a different way because Rex said in a post that the import from method works only with webpack.
RexRainbow Round Rectangle Plugin
You must try using the plugin from the game config.
I’m not totally sure, but it can help
Here is the post -
How to install a plugin(Board plugin from Rex)
Thanks for this suggestion, I will try to add more instructions of installing plugin.
2 Likes
Andrio
January 18, 2020, 6:59pm
8
Thanks, but what should i write in code if I want use webpack? Now I just installed webpack, and don’t know how to use. Or is it possibly to run plugin without webpack ?
I recommend this project to use a modular project with webpack https://github.com/lean/phaser-es6-webpack
Added install instructions in each plugin.
Here is an install instructions of round-rectangle game object, with import
and webpack.
1 Like