Issue
I'm trying to use this lib in my Ionic 4 app:
https://github.com/jjcapellan/Phaser3-ScrollingCamera
As README says, I've download the script file and added to my HTML:
<body>
<app-root></app-root>
<script src="/assets/scripts/scrollcam.min.js"></script>
</body>
So in my Scene I've added:
...
export class BlankSceneService extends Phaser.Scene {
public myCamera = new ScrollingCamera(this);
...
But when I try to compile my Ionic 4 app, it stops on this error:
[ng] ERROR in src/app/services/blank-scene.service.ts(17,25): error TS2304: Cannot find name 'ScrollingCamera'.
It looks like I need to import
this class in scene script.
Is that correct? How can I do that?
Solution
Add your script file to your angular.json
in the script section
"scripts": [
.....
"/assets/scripts/scrollcam.min.js"
]
Now you have to declare ScrollingCamera
and then use it:
declare const ScrollingCamera: any;
export class BlankSceneService extends Phaser.Scene {
public myCamera = new ScrollingCamera(this);
}
Answered By - Norbert Bartko
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.