Jump to content

TypeError: this.game.add is not a function


Recommended Posts

I'm trying to use a dragon bones plug in (https://github.com/raksa/phaser-dragonbones#need-help)

The example is using a single state and to add the character to the game this is used:

var sprite = this.dragonBonesPlugin.getArmature("key");


I'm trying to empliment this in a state system where my game is defined with the game variable passed in:

var theGame = function(game){  etc.

Adding normal sprites works like this:

this.screenshot = this.game.add.sprite(0, 0, 'ss');

But for some reason trying to add the dragon bones animation like this:

this.character = this.dragonBonesPlugin.getArmature('key')

is giving me this error 'TypeError: this.game.add is not a function'

Does anyone know what the issue could be?  I found this forum which sounds like it has kind of the same issue:

I've tried some of the solutions mentioned(like adding 'use strict') but nothing has worked.  Any clues?


Here is a screen shot of the error info.  Could it have something to do with the loading?







Link to comment
Share on other sites

  • 3 weeks later...
  • 4 weeks later...

can you provide the code where you make the dragon bones armature and then retrieve it back? I am not sure from your error log where the original break happened, because it doesn't even go into the dragon bones plugin. getarmature expects a root armaturename, so if that is not set, it could cause the issue. if you don't provide enough code to compare against the plugin, then it might not be possible to troubleshoot your issue. try to console.log the sprite before adding it to the game and see what that brings up.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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