Author Topic: Grouped Sprite [NOT solved]  (Read 705 times)

superbany

  • Member
  • **
  • Posts: 53
  • Karma: +0/-0
  • [Please enter text here]
    • View Profile
    • Superbany's games
Grouped Sprite [NOT solved]
« on: Mon, Dec 13, 2010 »
I tried this earlier and gave up on it, but I found that I'll have to do it anyways, and I might as well try to do it now.

I'm making a platformer, and I want the player to consist of multiple sprites, one for the body and one for the eyes, with different animations based on moving/aiming direction.

I previously had two objects added to PlayState, one <Player> and one <PlayerEyes>, both of which were sprites. PlayState in its update would use _playerEyes.setDirection(_player.knifeAngle) to determine what direction the eyes should face. And this has been working perfectly until now.

I decided that I should make it that the player cannot swim forever in water, and that they have to drown eventually. To do this, I needed an _air variable in _player, which would decrease when both _player and _playerEyes were overlapping water, but not if the eyes were above.

I could do it as it is, but I realized that it would be a whole lot more efficient to have one <PlayerGroup>, which contained two public sprites, playerBody and playerEyes. The PlayerGroup would have many miscellaneous variables, such as _canWallJump, _greenKeys, and _air.

Is there any way to easily convert my two sprites to one group?

-Also, I've tried making the group from the ground up, with the body being the only current member, but for some reason it is not colliding with the tilemap when I call FlxU.collide(PlayerGroup.playerBody, tiles) in PlayState's update. Any solutions?
« Last Edit: Mon, Dec 20, 2010 by superbany »

superbany

  • Member
  • **
  • Posts: 53
  • Karma: +0/-0
  • [Please enter text here]
    • View Profile
    • Superbany's games
Re: Grouped Sprite
« Reply #1 on: Fri, Dec 17, 2010 »
Since nobody seems to have an answer, I'll try rephrasing my question.

What would be the best way to create a multi-sprite group, which could contain all the miscellaneous variables and handle collision?