瀏覽代碼

[cocos2dx] Fixed formatting, removed printf...

badlogic 8 年之前
父節點
當前提交
ca23700db0

+ 3 - 1
spine-cocos2dx/example/Classes/BatchingExample.cpp

@@ -65,7 +65,7 @@ bool BatchingExample::init () {
 
 	int xMin = _contentSize.width * 0.10f, xMax = _contentSize.width * 0.90f;
 	int yMin = 0, yMax = _contentSize.height * 0.7f;
-	for (int i = 0; i < 500; i++) {
+	for (int i = 0; i < 100; i++) {
 		// Each skeleton node shares the same atlas, skeleton data, and mix times.
 		SkeletonAnimation* skeletonNode = SkeletonAnimation::createWithData(_skeletonData, false);
 		skeletonNode->setAnimationStateData(_stateData);
@@ -73,6 +73,8 @@ bool BatchingExample::init () {
 		skeletonNode->setAnimation(0, "walk", true);
 		skeletonNode->addAnimation(0, "jump", true, RandomHelper::random_int(0, 300) / 100.0f);
 		skeletonNode->addAnimation(0, "run", true);
+		
+		skeletonNode->setTwoColorTint(true);
 
 		skeletonNode->setPosition(Vec2(
 			RandomHelper::random_int(xMin, xMax),

+ 4 - 4
spine-cocos2dx/example/Classes/GoblinsExample.cpp

@@ -43,11 +43,11 @@ Scene* GoblinsExample::scene () {
 bool GoblinsExample::init () {
 	if (!LayerColor::initWithColor(Color4B(128, 128, 128, 255))) return false;
 
-	skeletonNode = SkeletonAnimation::createWithJsonFile("goblins-mesh.json", "goblins.atlas", 1.5f);
-	skeletonNode->setAnimation(0, "walk", true);
-	skeletonNode->setSkin("goblin");
+	skeletonNode = SkeletonAnimation::createWithBinaryFile("TwoColorTest.skel", "TwoColorTest.atlas", 0.5f);
+	skeletonNode->setAnimation(0, "animation", true);
+	// skeletonNode->setSkin("goblin");
 
-	skeletonNode->setPosition(Vec2(_contentSize.width / 2, 20));
+	skeletonNode->setPosition(Vec2(_contentSize.width / 2, _contentSize.height / 2));
 	addChild(skeletonNode);
 
 	scheduleUpdate();

+ 1 - 1
spine-cocos2dx/example/Classes/TankExample.cpp

@@ -44,7 +44,7 @@ bool TankExample::init () {
 	if (!LayerColor::initWithColor(Color4B(128, 128, 128, 255))) return false;
 
 	skeletonNode = SkeletonAnimation::createWithJsonFile("tank.json", "tank.atlas", 0.5f);
-	skeletonNode->setAnimation(0, "drive", true);
+	skeletonNode->setAnimation(0, "drive", true);	
 
 	skeletonNode->setPosition(Vec2(_contentSize.width / 2 + 400, 20));
 	addChild(skeletonNode);

+ 4 - 13
spine-cocos2dx/src/spine/SkeletonTwoColorBatch.cpp

@@ -43,13 +43,7 @@ using std::max;
 
 namespace spine {
 
-TwoColorTrianglesCommand::TwoColorTrianglesCommand()
-:_materialID(0)
-,_textureID(0)
-,_glProgramState(nullptr)
-,_glProgram(nullptr)
-,_blendType(BlendFunc::DISABLE)
-,_alphaTextureID(0) {
+TwoColorTrianglesCommand::TwoColorTrianglesCommand() :_materialID(0), _textureID(0), _glProgramState(nullptr), _glProgram(nullptr), _blendType(BlendFunc::DISABLE), _alphaTextureID(0) {
 	_type = RenderCommand::Type::CUSTOM_COMMAND;
 	func = [this]() { draw(); };
 }
@@ -83,8 +77,7 @@ void TwoColorTrianglesCommand::init(float globalOrder, GLuint textureID, GLProgr
 TwoColorTrianglesCommand::~TwoColorTrianglesCommand() {
 }
 
-void TwoColorTrianglesCommand::generateMaterialID()
-{
+void TwoColorTrianglesCommand::generateMaterialID() {
 	// do not batch if using custom uniforms (since we cannot batch) it
 	if(_glProgramState->getUniformCount() > 0) {
 		_materialID = Renderer::MATERIAL_ID_DO_NOT_BATCH;
@@ -97,8 +90,7 @@ void TwoColorTrianglesCommand::generateMaterialID()
 	}
 }
 
-void TwoColorTrianglesCommand::useMaterial() const
-{
+void TwoColorTrianglesCommand::useMaterial() const {
 	//Set texture
 	GL::bindTexture2D(_textureID);
 	
@@ -212,8 +204,7 @@ SkeletonTwoColorBatch::~SkeletonTwoColorBatch () {
 	delete _indexBuffer;
 }
 
-void SkeletonTwoColorBatch::update (float delta) {
-	printf("Num batches: %i\n", _numBatches);
+void SkeletonTwoColorBatch::update (float delta) {	
 	reset();
 }