MCPcopy Create free account
hub / github.com/axmolengine/axmol / update

Method update

tests/cpp-tests/Source/ParallaxTest/ParallaxTest.cpp:191–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191void Issue2572::update(float dt)
192{
193 _addTimer += dt;
194 _moveTimer += dt;
195 if (_moveTimer >= _wholeMoveTime)
196 {
197 this->unscheduleUpdate();
198 return;
199 }
200
201 _paraNode->setPosition(_paraNode->getPosition() + _wholeMoveSize * dt / _wholeMoveTime);
202
203 if (_addTimer >= _addChildStep)
204 {
205 _addTimer = 0.0f;
206
207 auto child = Sprite::create("Images/Icon.png");
208 Size viewSize = Director::getInstance()->getVisibleSize();
209 Vec2 offset = Vec2(viewSize.width / 2, viewSize.height / 2);
210 _paraNode->addChild(child, 1, Vec2(1, 0), offset);
211
212 _childList.pushBack(child);
213 }
214
215 // After a child added, output the position of the children 3 times.
216 // Bug : The first output is much different with the second one & the third one.
217 if (_childList.size() != _preListSize)
218 {
219 switch (_printCount)
220 {
221 case 0:
222 case 1:
223 case 2:
224 AXLOGD("--child count-- {}", _childList.size());
225 for (const auto& obj : _childList)
226 {
227 Sprite* obstacle = dynamic_cast<Sprite*>(obj);
228 AXLOGD("child position : ({:.2}, {:.2})", obstacle->getPositionX(), obstacle->getPositionY());
229 }
230 AXLOGD("-------------------");
231 _printCount++;
232 break;
233 case 3:
234 _preListSize = _childList.size();
235 _printCount = 0;
236 break;
237 default:
238 break;
239 }
240 }
241}
242
243std::string Issue2572::title() const
244{

Callers

nothing calls this directly

Calls 12

createFunction · 0.85
getInstanceFunction · 0.85
pushBackMethod · 0.80
Vec2Function · 0.50
unscheduleUpdateMethod · 0.45
setPositionMethod · 0.45
getPositionMethod · 0.45
getVisibleSizeMethod · 0.45
addChildMethod · 0.45
sizeMethod · 0.45
getPositionXMethod · 0.45
getPositionYMethod · 0.45

Tested by

no test coverage detected