mirror of https://github.com/axmolengine/axmol.git
Nodes: setAdditionalTransform() receives a pointer
and not a const reference. If the pointer is `NULL`, then it won't use the additionalTransform
This commit is contained in:
parent
219ef6d897
commit
cdc19eea1c
|
@ -3,6 +3,7 @@ cocos2d-x-3.0rc0 Feb.?? 2014
|
||||||
[NEW] Action: RotateBy supports 3D rotations
|
[NEW] Action: RotateBy supports 3D rotations
|
||||||
[NEW] Bindings: Using python to automatically generate script bindings
|
[NEW] Bindings: Using python to automatically generate script bindings
|
||||||
[NEW] Bindings: Added JS bindings support for Linux
|
[NEW] Bindings: Added JS bindings support for Linux
|
||||||
|
[NEW] ccConfig.h: removed support for CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP
|
||||||
[NEW] Console: Added 'resolution', 'projection' commands. Improved API
|
[NEW] Console: Added 'resolution', 'projection' commands. Improved API
|
||||||
[NEW] Console: Added more commands: director resume|pause|stopanimation|startanimation.
|
[NEW] Console: Added more commands: director resume|pause|stopanimation|startanimation.
|
||||||
[NEW] Console: Added command: 'touch tap|swipe' to simulating touch events.
|
[NEW] Console: Added command: 'touch tap|swipe' to simulating touch events.
|
||||||
|
@ -48,6 +49,8 @@ cocos2d-x-3.0rc0 Feb.?? 2014
|
||||||
[FIX] EGLView improvements: renamed to GLView, no longer a singleton, easier to customize
|
[FIX] EGLView improvements: renamed to GLView, no longer a singleton, easier to customize
|
||||||
[FIX] Removes samples except testcpp|testjavascript|testlua. Moves sample games to `cocos2d/samples` repo.
|
[FIX] Removes samples except testcpp|testjavascript|testlua. Moves sample games to `cocos2d/samples` repo.
|
||||||
[FIX] cc.BuilderReader.load( path, null, parentSize ); was not allowed.
|
[FIX] cc.BuilderReader.load( path, null, parentSize ); was not allowed.
|
||||||
|
[FIX] Node: setAdditionalTransform receives a pointer and not a const reference
|
||||||
|
|
||||||
|
|
||||||
cocos2d-x-3.0beta2 Jan.24 2014
|
cocos2d-x-3.0beta2 Jan.24 2014
|
||||||
[All]
|
[All]
|
||||||
|
|
|
@ -122,7 +122,7 @@ void ActionCamera::updateTransform()
|
||||||
// But that operation needs to be done after all the 'updates'.
|
// But that operation needs to be done after all the 'updates'.
|
||||||
// So the Director should emit an 'director_after_update' event.
|
// So the Director should emit an 'director_after_update' event.
|
||||||
// And this object should listen to it
|
// And this object should listen to it
|
||||||
_target->setAdditionalTransform(mv);
|
_target->setAdditionalTransform(&mv);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -1361,16 +1361,20 @@ void Node::setNodeToParentTransform(const kmMat4& transform)
|
||||||
|
|
||||||
void Node::setAdditionalTransform(const AffineTransform& additionalTransform)
|
void Node::setAdditionalTransform(const AffineTransform& additionalTransform)
|
||||||
{
|
{
|
||||||
CGAffineToGL(additionalTransform, _additionalTransform.mat);
|
kmMat4 tmp;
|
||||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
CGAffineToGL(additionalTransform, tmp.mat);
|
||||||
_useAdditionalTransform = true;
|
setAdditionalTransform(&tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::setAdditionalTransform(const kmMat4& additionalTransform)
|
void Node::setAdditionalTransform(kmMat4* additionalTransform)
|
||||||
{
|
{
|
||||||
_additionalTransform = additionalTransform;
|
if(additionalTransform == nullptr) {
|
||||||
|
_useAdditionalTransform = false;
|
||||||
|
} else {
|
||||||
|
_additionalTransform = *additionalTransform;
|
||||||
|
_useAdditionalTransform = true;
|
||||||
|
}
|
||||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||||
_useAdditionalTransform = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1347,54 +1347,12 @@ public:
|
||||||
/**
|
/**
|
||||||
* Sets an additional transform matrix to the node.
|
* Sets an additional transform matrix to the node.
|
||||||
*
|
*
|
||||||
* In order to remove it, set the Identity Matrix to the additional transform.
|
* In order to remove it, call it again with the argument `nullptr`
|
||||||
*
|
*
|
||||||
* @note The additional transform will be concatenated at the end of getNodeToParentTransform.
|
* @note The additional transform will be concatenated at the end of getNodeToParentTransform.
|
||||||
* It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't).
|
* It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't).
|
||||||
@code
|
|
||||||
// create a batchNode
|
|
||||||
SpriteBatchNode* batch= SpriteBatchNode::create("Icon-114.png");
|
|
||||||
this->addChild(batch);
|
|
||||||
|
|
||||||
// create two sprites, spriteA will be added to batchNode, they are using different textures.
|
|
||||||
Sprite* spriteA = Sprite::createWithTexture(batch->getTexture());
|
|
||||||
Sprite* spriteB = Sprite::create("Icon-72.png");
|
|
||||||
|
|
||||||
batch->addChild(spriteA);
|
|
||||||
|
|
||||||
// We can't make spriteB as spriteA's child since they use different textures. So just add it to layer.
|
|
||||||
// But we want to simulate `parent-child` relationship for these two node.
|
|
||||||
this->addChild(spriteB);
|
|
||||||
|
|
||||||
//position
|
|
||||||
spriteA->setPosition(Point(200, 200));
|
|
||||||
|
|
||||||
// Gets the spriteA's transform.
|
|
||||||
auto t = spriteA->getNodeToParentTransform();
|
|
||||||
|
|
||||||
// Sets the additional transform to spriteB, spriteB's postion will based on its pseudo parent i.e. spriteA.
|
|
||||||
spriteB->setAdditionalTransform(t);
|
|
||||||
|
|
||||||
//scale
|
|
||||||
spriteA->setScale(2);
|
|
||||||
|
|
||||||
// Gets the spriteA's transform.
|
|
||||||
t = spriteA->getNodeToParentTransform();
|
|
||||||
|
|
||||||
// Sets the additional transform to spriteB, spriteB's scale will based on its pseudo parent i.e. spriteA.
|
|
||||||
spriteB->setAdditionalTransform(t);
|
|
||||||
|
|
||||||
//rotation
|
|
||||||
spriteA->setRotation(20);
|
|
||||||
|
|
||||||
// Gets the spriteA's transform.
|
|
||||||
t = spriteA->getNodeToParentTransform();
|
|
||||||
|
|
||||||
// Sets the additional transform to spriteB, spriteB's rotation will based on its pseudo parent i.e. spriteA.
|
|
||||||
spriteB->setAdditionalTransform(t);
|
|
||||||
@endcode
|
|
||||||
*/
|
*/
|
||||||
void setAdditionalTransform(const kmMat4& additionalTransform);
|
void setAdditionalTransform(kmMat4* additionalTransform);
|
||||||
void setAdditionalTransform(const AffineTransform& additionalTransform);
|
void setAdditionalTransform(const AffineTransform& additionalTransform);
|
||||||
|
|
||||||
/// @} end of Coordinate Converters
|
/// @} end of Coordinate Converters
|
||||||
|
|
|
@ -112,21 +112,18 @@ void TransitionScene::draw(Renderer *renderer, const kmMat4 &transform, bool tra
|
||||||
|
|
||||||
void TransitionScene::finish()
|
void TransitionScene::finish()
|
||||||
{
|
{
|
||||||
kmMat4 identity;
|
|
||||||
kmMat4Identity(&identity);
|
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
_inScene->setVisible(true);
|
_inScene->setVisible(true);
|
||||||
_inScene->setPosition(Point(0,0));
|
_inScene->setPosition(Point(0,0));
|
||||||
_inScene->setScale(1.0f);
|
_inScene->setScale(1.0f);
|
||||||
_inScene->setRotation(0.0f);
|
_inScene->setRotation(0.0f);
|
||||||
_inScene->setAdditionalTransform(identity);
|
_inScene->setAdditionalTransform(nullptr);
|
||||||
|
|
||||||
_outScene->setVisible(false);
|
_outScene->setVisible(false);
|
||||||
_outScene->setPosition(Point(0,0));
|
_outScene->setPosition(Point(0,0));
|
||||||
_outScene->setScale(1.0f);
|
_outScene->setScale(1.0f);
|
||||||
_outScene->setRotation(0.0f);
|
_outScene->setRotation(0.0f);
|
||||||
_outScene->setAdditionalTransform(identity);
|
_outScene->setAdditionalTransform(nullptr);
|
||||||
|
|
||||||
//[self schedule:@selector(setNewScene:) interval:0];
|
//[self schedule:@selector(setNewScene:) interval:0];
|
||||||
this->schedule(schedule_selector(TransitionScene::setNewScene), 0);
|
this->schedule(schedule_selector(TransitionScene::setNewScene), 0);
|
||||||
|
|
|
@ -93,7 +93,8 @@ void DisplayFactory::updateDisplay(Bone *bone, float dt, bool dirty)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
display->setAdditionalTransform(bone->getNodeToArmatureTransform());
|
kmMat4 transform = bone->getNodeToArmatureTransform();
|
||||||
|
display->setAdditionalTransform(&transform);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1107,8 +1107,8 @@ CameraTest2::CameraTest2()
|
||||||
kmMat4 lookupMatrix;
|
kmMat4 lookupMatrix;
|
||||||
kmMat4LookAt(&lookupMatrix, &eye, ¢er, &up);
|
kmMat4LookAt(&lookupMatrix, &eye, ¢er, &up);
|
||||||
|
|
||||||
_sprite1->setAdditionalTransform(lookupMatrix);
|
_sprite1->setAdditionalTransform(&lookupMatrix);
|
||||||
_sprite2->setAdditionalTransform(lookupMatrix);
|
_sprite2->setAdditionalTransform(&lookupMatrix);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue