#pragma once

#include "CBaseNode.h"
#include "CTweenNode.h"

using namespace cocos2d;

#define  ANGLE_TO_RADIAN  (M_PI / 180)


class CCBone : public CCObject
{
public:
	/**
	* BoneʵBone Ϊõʵöع
	* @param _isRadian תǶǷûƣ Starling ʹõǻ
	* @return  Bone ʵ
	*/
	static CCBone* create(bool _isRadian = false);

	static void	removePoolObject();

protected:

	static CCArray	*sObjectPool;

	static int		sPoolIndex;

	static void		recycle(CCBone* _bone);
	

public:

	/**
	* 캯
	* @param _isRadian תǶǷûƣ Starling ʹõǻ
	*/
	CCBone();
	~CCBone(void);

	virtual bool init(bool _isRadian);

	
	/* ɾ */
	void	remove();

	/* ӹ */
	void	addBoneChild(CCBone* _child);
	/* ڸеİλãӵ parent ʱ */
	void	setLockPosition(float _x, float _y, float _skewX = 0, float _skewY = 0);
	/* λ */
	void	update( float dt );
	/* ȡ Armatur.display еȫ x  */
	float	 getGlobalX();
	/* ȡ Armatur.display еȫ y  */
	float	getGlobalY();
	/* ȡ Armatur.display еȫ rotation */
	float	getGlobalR();
	float	getGlobalSkewX();
	float	getGlobalSkewY();


protected:

	/*  display */
	void updateDisplay();

	void reset();

public:

	/*  Armature ͨ BoneAnimation ͨ Bone  Tween Ĺ */	
	CC_SYNTHESIZE(const char *, mName, Name);
	
	/* 󶨵ʾ󣬲ǱģԲʾ */
	CC_SYNTHESIZE_RETAIN(CCNode	*, mDisplay, Display);

	/* ܿƵĹؼ */
	CC_SYNTHESIZE_RETAIN(CCBaseNode	*, mNode, Node);

	/*  Tween ƵĹؼ㣬 Tween  node ĺֵ */
	CC_SYNTHESIZE_RETAIN(CCTweenNode *, mTweenNode, TweenNode);

	CC_SYNTHESIZE(CCBone *, mParent, Parent);
	CC_SYNTHESIZE_PASS_BY_REF(std::string, mParentName, ParentName);

protected:
	
	bool	mIsRadian;
	float	mTransformX;
	float	mTransformY;
	float	mTransformSkewX;
	float	mTransformSkewY;
	float	mTransformRotation;
	float	mLockX;
	float	mLockY;
	float	mLockR;
	float	mLockSkewX;
	float	mLockSkewY;
	float	mParentX;
	float	mParentY;
	float	mParentR;
	float	mParentSkewX;
	float	mParentSkewY;

};

