s6reinan Posted February 22, 2017 Share Posted February 22, 2017 I can't seem to follow the example code for Creature animations. I'm getting this error: c.Creature is not a constructor Are there any other things I need to setup? Link to comment Share on other sites More sharing options...
samme Posted February 22, 2017 Share Posted February 22, 2017 Try adding photonstorm/phaser/blob/master/v2/build/creature.js after your phaser script. s6reinan 1 Link to comment Share on other sites More sharing options...
s6reinan Posted February 23, 2017 Author Share Posted February 23, 2017 13 hours ago, samme said: Try adding photonstorm/phaser/blob/master/v2/build/creature.js after your phaser script. Thanks. I created a custom build and made sure to include creature module. Link to comment Share on other sites More sharing options...
Zampano Posted June 9, 2017 Share Posted June 9, 2017 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 themloaded 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 More sharing options...
samme Posted June 9, 2017 Share Posted June 9, 2017 You should be able to use phaser-ce/build/custom/phaser-creature.js (2.8.0) or phaser/build/phaser-creature.js (2.6.2). Link to comment Share on other sites More sharing options...
Zampano Posted June 9, 2017 Share Posted June 9, 2017 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 More sharing options...
samme Posted June 9, 2017 Share Posted June 9, 2017 OK, try together phaser-ce/build/custom/creature.js phaser-ce/build/custom/phaser-creature.js Link to comment Share on other sites More sharing options...
Zampano Posted June 9, 2017 Share Posted June 9, 2017 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 More sharing options...
samme Posted June 10, 2017 Share Posted June 10, 2017 OK, it turns out you need custom/creature.js custom/p2.js custom/pixi.js custom/phaser-creature.js So phaser-creature actually substitutes for phaser-split. Link to comment Share on other sites More sharing options...
Zampano Posted June 10, 2017 Share Posted June 10, 2017 Works like a charm, thank you so much! Are there any modules I would be missing now compared to using the standard phaser 2.8.0 build? Link to comment Share on other sites More sharing options...
samme Posted June 11, 2017 Share Posted June 11, 2017 That should be everything in the standard build, plus Creature support. If you're interested you can also make your own custom build, since you probably don't need P2. Added phaser-ce/build/custom/README.md. Link to comment Share on other sites More sharing options...
Zampano Posted June 11, 2017 Share Posted June 11, 2017 I've read about this, too, but to be honest I didn't get a word of that grunt tutorial 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 More sharing options...
Recommended Posts