本文整理汇总了C++中PointObject::getOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ PointObject::getOffset方法的具体用法?C++ PointObject::getOffset怎么用?C++ PointObject::getOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointObject
的用法示例。
在下文中一共展示了PointObject::getOffset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: incrementOffset
void ParallaxNodeExtras::incrementOffset(Point offset, Node* node){
for (int i = 0; i < _parallaxArray->num; i++) {
PointObject *point = (PointObject *)_parallaxArray->arr[i];
Node * curNode = point->getChild();
if (curNode==/*->isEqual*/(node)) {
point->setOffset(point->getOffset() + offset);
break;
}
}
}
示例2: visit
void ParallaxContainer::visit(cocos2d::Renderer *renderer, const cocos2d::Mat4& parentTransform, uint32_t parentFlags)
{
Vec2 pos = parallaxPosition;
//if (!pos.equals(_lastPosition)) {
for( int i=0; i < _parallaxArray->num; i++ ) {
PointObject *point = (PointObject*)_parallaxArray->arr[i];
// auto scrolling
auto offset = point->getOffset();
offset.x += point->getAutoscroll().x;
offset.y += point->getAutoscroll().y;
point->setOffset(offset);
float x = pos.x * point->getRatio().x + point->getOffset().x;
float y = pos.y * point->getRatio().y + point->getOffset().y;
point->getChild()->setPosition({x, y});
}
_lastPosition = pos;
//}
Node::visit(renderer, parentTransform, parentFlags);
}
示例3: visit
/*
The positions are updated at visit because:
- using a timer is not guaranteed that it will called after all the positions were updated
- overriding "draw" will only precise if the children have a z > 0
*/
void ParallaxNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
// Vec2 pos = position_;
// Vec2 pos = [self convertToWorldSpace:Vec2::ZERO];
Vec2 pos = this->absolutePosition();
if( ! pos.equals(_lastPosition) )
{
for( int i=0; i < _parallaxArray->num; i++ )
{
PointObject *point = (PointObject*)_parallaxArray->arr[i];
float x = -pos.x + pos.x * point->getRatio().x + point->getOffset().x;
float y = -pos.y + pos.y * point->getRatio().y + point->getOffset().y;
point->getChild()->setPosition(x,y);
}
_lastPosition = pos;
}
Node::visit(renderer, parentTransform, parentFlags);
}