您的位置:首页 > Web前端 > Node.js

无限循环背景ParallaxNode

2016-02-16 13:16 561 查看
无限循环背景

void  ParallaxNode::incrementoffset(Point offset, Node*  node)
{
for (unsigned int i = 0; i < _parallaxArray->num; ++i)
{
PointObject*  point = (PointObject*)_parallaxArray->arr[i];
Node*  curNode = point->getChild();
if (curNode == node)
{
point->setOffset(point->getOffset()+ offset);
}
}
}
每移动一完就incrementoffset
function InfiniteBg:update(dt)
for k,bg in pairs(self.bgs) do
local p = cc.p(bg:getPosition())
local width = bg:getContentSize().width;
p = self:convertToWorldSpace(p)
if (p.x < -width) then
print("[InfiniteBg] : repeat bg")
self:incrementoffset(cc.p(width,0),bg);
end
end
end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: