We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
现在每次调用新建都不得不重读文件,太慢了,需要预加载! 如:
// 发射子弹,father 中有需要的内容 BaseObject* NewBullet(BaseObject* father, const std::string& name) { // 问题-> Json::Value objectData = readJsonFromFile(BULLETS); const Json::Value object = objectData["bullets"][name]; if (object == NULL) return nullptr; BaseObject* newObject = new BaseObject(5, false, nullptr, spriteMap[name], nullptr, nullptr, false); // sprite float fireSpeed = father->variable["fireSpeed"]; float fireAngle = father->variable["fireAngle"]; newObject->mass = object["sprite"]["mass"].asFloat(); newObject->health = object["sprite"]["health"].asFloat(); newObject->maxSpeed = object["sprite"]["maxSpeed"].asFloat(); newObject->maxSpeedAngle = object["sprite"]["maxSpeedAngle"].asFloat(); newObject->friction = object["sprite"]["friction"].asFloat(); newObject->frictionAngle = object["sprite"]["frictionAngle"].asFloat(); newObject->angle = father->angle + RandomNumber(-fireAngle, fireAngle); float Angle = Remainder(newObject->angle, 360) * (float)acos(-1) / 180; newObject->speedX = father->speedX + fireSpeed * sin(Angle); newObject->speedY = father->speedX + fireSpeed * cos(Angle); newObject->x = father->x; newObject->y = father->y; // variable newObject->variable["rotateAcceleration"] = object["sprite"]["rotateAcceleration"].asFloat(); newObject->variable["forceAcceleration"] = object["sprite"]["forceAcceleration"].asFloat(); newObject->variable["maxForce"] = object["sprite"]["maxForce"].asFloat(); newObject->variable["liftTime"] = object["sprite"]["maxForce"].asFloat(); // collisionBox for (const Json::Value point : object["collisionBox"]) easy2d::Point(point[0].asFloat(), point[1].asFloat()); newObject->Init(); // 初始化 return newObject; }
在下个dev提交修改
The text was updated successfully, but these errors were encountered:
已在6ed3d6c提交中解决此问题
6ed3d6c
Sorry, something went wrong.
重新启用BaseObject复制函数,所有文件应该在启动前读完,Json::Value也必须在加载之后销毁
BaseObject
Json::Value
此条作废
EveSunMaple
No branches or pull requests
现在每次调用新建都不得不重读文件,太慢了,需要预加载!
如:
在下个dev提交修改
The text was updated successfully, but these errors were encountered: