@rhythmcoder wrote:
Following code is typical source of Box2d Raycasting in cocos2dx.
I can get many information like 'Rocation', 'Scale', 'Name', 'Tag'... etc by 'Sprite->getXXXXX'
But I made this game using 'Player' class. Player class include 'Sprite *m_pPlayerSprite' one by one.
I want get information like 'ItemTag', 'ModeTag' of 'Player' class of Raycasted PlayerSprite.But I don't have good idea.
Is there any way to get information?
(Sorry for my pool English)
float32 EnemyAI::ReportFixture(b2Fixture* fixture, const b2Vec2& point, const b2Vec2& normal, float32 fraction) { b2Body* body = fixture->GetBody(); CCSprite *Sprite = (CCSprite*)body->GetUserData(); // spriteA am getting null if (Sprite == NULL) { CCLOG("Body has no user data!"); return 1; } if (Sprite < 0) { return 1; } if (Sprite->getTag() == TAG_SPRITE_PLAYER) { CCLOG("Tag is Player!"); CCLOG("Rotate of Player = %f", Sprite->getRotation()); return 0; } return 0; } class Player : public cocos2d::Layer { private: Size m_WinSize; Size m_VisibleSize; Vec2 m_Origin; Sprite *m_pPlayerSprite; int m_iType; int m_iEatObject; SpriteFrameCache* m_pSpriteCache; LPTILEMAP m_pTileMap; float m_PlayerSpeed; int m_ItemTag; int m_ModeTag; };
Posts: 1
Participants: 1