Jump to content

c.Creature is not a constructor


s6reinan
 Share

Recommended Posts

  • 3 months later...

I'm having the same problem.. Especially with the newest phaser version 2.8 I can't get it to work. If someone could extend the demo script so that it will run outside of the phaser example environment, that would be great. I also tried the very different approach in the creature documentation but that also doesn't work with a current phaser version. :(

Edit: Spoke to the creator of creature. He says I should ask here since the problem with his approach seems to be the effect of a semantics change in phaser. However, the phaser example code is much more straight forward and I would want to use that. So I would really appreciate any help with importing the right files to make it work. Adding creature.js did not do the trick unfortunately. I'm trying all kinds of combinations, but it's alwways "Phaser.Creature is not a constructor".


        <script src="phaser28.js"></script>
        <script src="creature/gl-matrix.js"></script>
        <script src="creature/flatbuffers.js"></script>
        <script src="creature/CreatureFlatData_generated.js"></script>
        <script src="creature/CreatureMeshBone.js"></script>
        <script src="creature/CreaturePixiJSRenderer.js"></script>
        <script src="creature/CreaturePhaserRenderer.js"></script>

 

These seem to be the options I have, respectively what the creature examples suggest. The phaser version itself should include all modules though, so I am wondering if it even makes sense to add anything else, since it says here : 

"You must use a build of Phaser that includes the CreatureMeshBone.js runtime and gl-matrix.js, or have them
loaded before your Phaser game boots."

But yeah, with or without them it wont work.:(

 

Edit 2: If it helps, it's "phaser28.js:47283 - Uncaught TypeError: Phaser.Creature is not a constructor" and this code:

 creature: function (x, y, key, mesh, group) {

        if (group === undefined) { group = this.world; }

        var obj = new Phaser.Creature(this.game, x, y, key, mesh);

        group.add(obj);

        return obj;

    },

The "new Phaser.Creature" to be exact.

Link to comment
Share on other sites

When I load this one (2.8.0), and nothing else, I get this:

phaser-creature.js:82925 Uncaught ReferenceError: Creature is not defined
    at new Phaser.Creature (phaser-creature.js:82925)
    at Phaser.GameObjectFactory.creature (phaser-creature.js:26132)
    at Object.create (PHd.html:35)
    at Phaser.StateManager.loadComplete (phaser-creature.js:7461)
    at Phaser.Loader.finishedLoading (phaser-creature.js:54418)
    at Phaser.Loader.processLoadQueue (phaser-creature.js:54373)
    at Phaser.Loader.asyncComplete (phaser-creature.js:54445)
    at Phaser.Loader.fileComplete (phaser-creature.js:55328)
    at HTMLImageElement.file.data.onload (phaser-creature.js:54715)

:/

Edit:

If it helps, this is my code:

<!doctype html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>hello phaser!</title>
        <script src="phaser-creature.js"></script>
    </head>
    <body>

    <script type="text/javascript">

    window.onload = function() {

       
		var game = new Phaser.Game(800, 600, Phaser.WEBGL, 'phaser-example', { preload: preload, create: create });

		function preload() {
			
			game.load.image('testTexture', 'testexport_character_img.png');
			game.load.json('testAnim', 'testexport_character_data.json');

		}

		var dragon = null;

		function create() {

			dragon = game.add.creature(450, 350, 'testTexture', 'testAnim');
			
			dragon.play(true); //  true = loop

		}
				

		};

    </script>

    </body>
</html>

It's exactly the dragon example though.

Link to comment
Share on other sites

Okay, I'm a little bit confused now, I seem to have made a mistake before. Now it's as follows: 

- with only phaser-creature.js 2.8.0:


PHd.html:15 Uncaught ReferenceError: Phaser is not defined
    at window.onload (PHd.html:15)

phaser-creature280.js:583 Uncaught ReferenceError: PIXI is not defined
    at phaser-creature280.js:583
    at phaser-creature280.js:85017
(anonymous) @ phaser-creature280.js:583
(anonymous) @ phaser-creature280.js:85017

PHd.html:15 Uncaught ReferenceError: Phaser is not defined
    at window.onload (PHd.html:15)
window.onload @ PHd.html:15

- with creature.js loaded after I get this additionally in between of those two errors:

creature.js:42 Uncaught ReferenceError: Phaser is not defined
    at creature.js:42

 

Link to comment
Share on other sites

I've read about this, too, but to be honest I didn't get a word of that grunt tutorial :D

so thanks again for the creature solution :)

One thing I noticed, too is that there seems to be a problem with the variable isPlaying in the creaturemanager. When I play the animation with repeat = false, isPlaying never gets reset to false after finishing the playthrough. Of course it's easy to work around but maybe you would want to know that.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...