mirror of https://github.com/axmolengine/axmol.git
Merge pull request #10734 from pipu/projectnode_animation_innerspeed
Serialize and parse attribute "innerspeed" for ProjectNode.
This commit is contained in:
commit
65926a9f0b
|
@ -854,6 +854,7 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree)
|
||||||
reader->setPropsWithFlatBuffers(node, options->data());
|
reader->setPropsWithFlatBuffers(node, options->data());
|
||||||
if (action)
|
if (action)
|
||||||
{
|
{
|
||||||
|
action->setTimeSpeed(projectNodeOptions->innerActionSpeed());
|
||||||
node->runAction(action);
|
node->runAction(action);
|
||||||
action->gotoFrameAndPause(0);
|
action->gotoFrameAndPause(0);
|
||||||
}
|
}
|
||||||
|
@ -1187,6 +1188,7 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod
|
||||||
reader->setPropsWithFlatBuffers(node, options->data());
|
reader->setPropsWithFlatBuffers(node, options->data());
|
||||||
if (action)
|
if (action)
|
||||||
{
|
{
|
||||||
|
action->setTimeSpeed(projectNodeOptions->innerActionSpeed());
|
||||||
node->runAction(action);
|
node->runAction(action);
|
||||||
action->gotoFrameAndPause(0);
|
action->gotoFrameAndPause(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1685,12 +1685,14 @@ inline flatbuffers::Offset<ListViewOptions> CreateListViewOptions(flatbuffers::F
|
||||||
struct ProjectNodeOptions : private flatbuffers::Table {
|
struct ProjectNodeOptions : private flatbuffers::Table {
|
||||||
const WidgetOptions *nodeOptions() const { return GetPointer<const WidgetOptions *>(4); }
|
const WidgetOptions *nodeOptions() const { return GetPointer<const WidgetOptions *>(4); }
|
||||||
const flatbuffers::String *fileName() const { return GetPointer<const flatbuffers::String *>(6); }
|
const flatbuffers::String *fileName() const { return GetPointer<const flatbuffers::String *>(6); }
|
||||||
|
float innerActionSpeed() const { return GetField<float>(8, 0); }
|
||||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* nodeOptions */) &&
|
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* nodeOptions */) &&
|
||||||
verifier.VerifyTable(nodeOptions()) &&
|
verifier.VerifyTable(nodeOptions()) &&
|
||||||
VerifyField<flatbuffers::uoffset_t>(verifier, 6 /* fileName */) &&
|
VerifyField<flatbuffers::uoffset_t>(verifier, 6 /* fileName */) &&
|
||||||
verifier.Verify(fileName()) &&
|
verifier.Verify(fileName()) &&
|
||||||
|
VerifyField<float>(verifier, 8 /* innerActionSpeed */) &&
|
||||||
verifier.EndTable();
|
verifier.EndTable();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1700,18 +1702,21 @@ struct ProjectNodeOptionsBuilder {
|
||||||
flatbuffers::uoffset_t start_;
|
flatbuffers::uoffset_t start_;
|
||||||
void add_nodeOptions(flatbuffers::Offset<WidgetOptions> nodeOptions) { fbb_.AddOffset(4, nodeOptions); }
|
void add_nodeOptions(flatbuffers::Offset<WidgetOptions> nodeOptions) { fbb_.AddOffset(4, nodeOptions); }
|
||||||
void add_fileName(flatbuffers::Offset<flatbuffers::String> fileName) { fbb_.AddOffset(6, fileName); }
|
void add_fileName(flatbuffers::Offset<flatbuffers::String> fileName) { fbb_.AddOffset(6, fileName); }
|
||||||
|
void add_innerActionSpeed(float innerActionSpeed) { fbb_.AddElement<float>(8, innerActionSpeed, 0); }
|
||||||
ProjectNodeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
ProjectNodeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||||
ProjectNodeOptionsBuilder &operator=(const ProjectNodeOptionsBuilder &);
|
ProjectNodeOptionsBuilder &operator=(const ProjectNodeOptionsBuilder &);
|
||||||
flatbuffers::Offset<ProjectNodeOptions> Finish() {
|
flatbuffers::Offset<ProjectNodeOptions> Finish() {
|
||||||
auto o = flatbuffers::Offset<ProjectNodeOptions>(fbb_.EndTable(start_, 2));
|
auto o = flatbuffers::Offset<ProjectNodeOptions>(fbb_.EndTable(start_, 3));
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline flatbuffers::Offset<ProjectNodeOptions> CreateProjectNodeOptions(flatbuffers::FlatBufferBuilder &_fbb,
|
inline flatbuffers::Offset<ProjectNodeOptions> CreateProjectNodeOptions(flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
flatbuffers::Offset<WidgetOptions> nodeOptions = 0,
|
flatbuffers::Offset<WidgetOptions> nodeOptions = 0,
|
||||||
flatbuffers::Offset<flatbuffers::String> fileName = 0) {
|
flatbuffers::Offset<flatbuffers::String> fileName = 0,
|
||||||
|
float innerActionSpeed = 0) {
|
||||||
ProjectNodeOptionsBuilder builder_(_fbb);
|
ProjectNodeOptionsBuilder builder_(_fbb);
|
||||||
|
builder_.add_innerActionSpeed(innerActionSpeed);
|
||||||
builder_.add_fileName(fileName);
|
builder_.add_fileName(fileName);
|
||||||
builder_.add_nodeOptions(nodeOptions);
|
builder_.add_nodeOptions(nodeOptions);
|
||||||
return builder_.Finish();
|
return builder_.Finish();
|
||||||
|
|
|
@ -69,6 +69,21 @@ namespace cocostudio
|
||||||
auto nodeOptions = *(Offset<WidgetOptions>*)(&temp);
|
auto nodeOptions = *(Offset<WidgetOptions>*)(&temp);
|
||||||
|
|
||||||
std::string filename = "";
|
std::string filename = "";
|
||||||
|
float innerspeed = 1.0f;
|
||||||
|
|
||||||
|
const tinyxml2::XMLAttribute* objattri = objectData->FirstAttribute();
|
||||||
|
// inneraction speed
|
||||||
|
while (objattri)
|
||||||
|
{
|
||||||
|
std::string name = objattri->Name();
|
||||||
|
std::string value = objattri->Value();
|
||||||
|
if (name == "InnerActionSpeed")
|
||||||
|
{
|
||||||
|
innerspeed = atof(objattri->Value());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
objattri = objattri->Next();
|
||||||
|
}
|
||||||
|
|
||||||
// FileData
|
// FileData
|
||||||
const tinyxml2::XMLElement* child = objectData->FirstChildElement();
|
const tinyxml2::XMLElement* child = objectData->FirstChildElement();
|
||||||
|
@ -101,7 +116,8 @@ namespace cocostudio
|
||||||
|
|
||||||
auto options = CreateProjectNodeOptions(*builder,
|
auto options = CreateProjectNodeOptions(*builder,
|
||||||
nodeOptions,
|
nodeOptions,
|
||||||
builder->CreateString(filename));
|
builder->CreateString(filename),
|
||||||
|
innerspeed);
|
||||||
|
|
||||||
return *(Offset<Table>*)(&options);
|
return *(Offset<Table>*)(&options);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue