azerion / phaser-spine

A plugin for Phaser 2 that adds Spine support
MIT License
121 stars 57 forks source link

[Spine-TS] Spine object affects unrelated group(s)/sprite(s)? #79

Open shibekin69 opened 6 years ago

shibekin69 commented 6 years ago

This one's a little elusive. I'm not sure how or why, but I'm sure the old phaser-spine doesn't cause this. There are two problems here that may be related to each other:

PROBLEM 1:

I have a bunch of groups that has a mix of groups, text, and sprite objects, that's separate from the group containing the spine object. Let's say we have this:

menuGroup --> This is the menu group containing a mix of groups, texts, and sprites. bgGroup --> This is another group containing child subgroups for different layers that contains sprites. The sprites aren't related to charGroup. charGroup --> This group contains groups and spine objects.

*When I say group here, I mean using Phaser's group feature.

In one of the the bgGroup subgroup, let's say bgGroup.layer6, I was tweening its alpha, and noticed that it suddenly affected a spine objects in charGroup. When I tween it to alpha 0, it the spine object followed. When the tween was done, the spine object's alpha went back to 100 while the bgGroup sprite I was tweening remained with alpha 0.

I tried adjusting the alpha of the bgGroup.layer6, and sprite in this subgroup and they both affect all the spine objects on screen.

PROBLEM 2:

In another instance, I noticed one of the subgroups in my menuGroup disappearing. I can't tell exactly when and this seems to happen depending on what's being loaded up. In the title screen, this menu group can be seen, and when I transition to the game state by a load game, it sometimes remains, and sometimes disppears depending on the loaded scene.

EDITED FOR MORE DETAIL.

shibekin69 commented 6 years ago

I looked over the different builds available and found that there's something between these two builds that cause my sprites to disappear:

Added support for multipage atlasses e91d69a103673ad5a90047117c047c956f8784a1

Direct link to build js: https://raw.githubusercontent.com/orange-games/phaser-spine/e91d69a103673ad5a90047117c047c956f8784a1/build/phaser-spine.js

Added premultiplied alpha support 2aa2370cf5bbd96e962c3f497623941379f32d75

Direct link to build js: https://raw.githubusercontent.com/orange-games/phaser-spine/2aa2370cf5bbd96e962c3f497623941379f32d75/build/phaser-spine.js

I'll see what might be causing it.

shibekin69 commented 6 years ago

I think I managed to trace the difference that causes the problem.

The earlier 2aa2370cf5bbd96e962c3f497623941379f32d75 build had this line:

var _this = _super.call(this, game, x, y, PhaserSpine.SpinePlugin.SPINE_NAMESPACE + key) || this;

Then the next e91d69a103673ad5a90047117c047c956f8784a1 build had this instead:

var _this = _super.call(this, game, x, y, '') || this;

I tried reverting this line in the latest version and it seems to do the trick for PROBLEM 2. No more disappearing sprite/group containers. This doesn't fix PROBLEM 1 however.

shibekin69 commented 6 years ago

Ok, so when I reverted back to the old code, I'm getting cache.image not found messages. But if I use the new one, I don't get these. However, the new code with the key name blank does cause some of my loaded sprites in the game to "disappear" from view. Of which, I don't know how it's happening. Hmm. But for now, I'll have to try to supress this key from being loaded, since it's trying to do:

spine load key "hero"

when we've changed it to load

spine load key "hero.png", "hero1.png" ...

To support multi page atlases...

shibekin69 commented 6 years ago

@AleBles - how does

_super.call(this, game, x, y, PhaserSpine.SpinePlugin.SPINE_NAMESPACE + key) || this;

work? So Spine extends a Phaser Sprite object, and calling this function will automatically try to look for an existing sprite with above key name?

shibekin69 commented 6 years ago

Ok, well, this works at supressing those error messages. My spine stuff seems to be loading...

var _this = _super.call(this, game, x, y, key + ".png") || this;

The assumption tho, is it's always looking for a png file, so the files are not png, like jpg or gif, there's always an cache.image error message (that won't affect the game, just bothersome messages in the console.)