ptotheaul Posted November 16, 2017 Share Posted November 16, 2017 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"); this.world.add(sprite); 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') this.game.add(this.character); 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 More sharing options...
gauravD Posted December 1, 2017 Share Posted December 1, 2017 Perhaps, you are looking for this.game.add.existing(). Try, this.game.add.existing(this.character); Link to comment Share on other sites More sharing options...
QLNEO Posted December 1, 2017 Share Posted December 1, 2017 game.add is indeed not a function. It's a reference to GameObjectFactory, which itself has methods like .sprite(), .group() and, as gauravD mentioned, .existing(), which is great when you have to add a generic GameObject. in mono 1 Link to comment Share on other sites More sharing options...
jimanji Posted December 28, 2017 Share Posted December 28, 2017 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 More sharing options...
Recommended Posts