voID shakeNode(cocos2d::Node *node,float duration,float rate){ Vec2 pos = node->getposition(); float tmp =0; float zs = node->getScale(); schedule([=](float dt) mutable { tmp += dt; if (tmp>=duration) { unschedule("updateShake"); node->setposition(pos); node->setScale(zs); return ; } else { float z = (arc4random()%5+98) * 0.01f; cclOG("z=%f",z); float x = arc4random() % 3 + 1; float y = arc4random() % 4 + 1; int r = arc4random() % 2; if (r>0) { x *= -1; r = arc4random() % 2; if (r>0) { y *= -1; } } node->setposition(x,y); node->setScale(z); } },rate,"updateShake");}总结
以上是内存溢出为你收集整理的模拟屏幕震动效果,使用cocos2d-x 3.x全部内容,希望文章能够帮你解决模拟屏幕震动效果,使用cocos2d-x 3.x所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)