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());
|
||||
if (action)
|
||||
{
|
||||
action->setTimeSpeed(projectNodeOptions->innerActionSpeed());
|
||||
node->runAction(action);
|
||||
action->gotoFrameAndPause(0);
|
||||
}
|
||||
|
@ -1187,6 +1188,7 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod
|
|||
reader->setPropsWithFlatBuffers(node, options->data());
|
||||
if (action)
|
||||
{
|
||||
action->setTimeSpeed(projectNodeOptions->innerActionSpeed());
|
||||
node->runAction(action);
|
||||
action->gotoFrameAndPause(0);
|
||||
}
|
||||
|
|
|
@ -1685,12 +1685,14 @@ inline flatbuffers::Offset<ListViewOptions> CreateListViewOptions(flatbuffers::F
|
|||
struct ProjectNodeOptions : private flatbuffers::Table {
|
||||
const WidgetOptions *nodeOptions() const { return GetPointer<const WidgetOptions *>(4); }
|
||||
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 {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* nodeOptions */) &&
|
||||
verifier.VerifyTable(nodeOptions()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 6 /* fileName */) &&
|
||||
verifier.Verify(fileName()) &&
|
||||
VerifyField<float>(verifier, 8 /* innerActionSpeed */) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
@ -1700,18 +1702,21 @@ struct ProjectNodeOptionsBuilder {
|
|||
flatbuffers::uoffset_t start_;
|
||||
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_innerActionSpeed(float innerActionSpeed) { fbb_.AddElement<float>(8, innerActionSpeed, 0); }
|
||||
ProjectNodeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
ProjectNodeOptionsBuilder &operator=(const ProjectNodeOptionsBuilder &);
|
||||
flatbuffers::Offset<ProjectNodeOptions> Finish() {
|
||||
auto o = flatbuffers::Offset<ProjectNodeOptions>(fbb_.EndTable(start_, 2));
|
||||
auto o = flatbuffers::Offset<ProjectNodeOptions>(fbb_.EndTable(start_, 3));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<ProjectNodeOptions> CreateProjectNodeOptions(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
flatbuffers::Offset<WidgetOptions> nodeOptions = 0,
|
||||
flatbuffers::Offset<flatbuffers::String> fileName = 0) {
|
||||
flatbuffers::Offset<flatbuffers::String> fileName = 0,
|
||||
float innerActionSpeed = 0) {
|
||||
ProjectNodeOptionsBuilder builder_(_fbb);
|
||||
builder_.add_innerActionSpeed(innerActionSpeed);
|
||||
builder_.add_fileName(fileName);
|
||||
builder_.add_nodeOptions(nodeOptions);
|
||||
return builder_.Finish();
|
||||
|
|
|
@ -69,6 +69,21 @@ namespace cocostudio
|
|||
auto nodeOptions = *(Offset<WidgetOptions>*)(&temp);
|
||||
|
||||
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
|
||||
const tinyxml2::XMLElement* child = objectData->FirstChildElement();
|
||||
|
@ -101,7 +116,8 @@ namespace cocostudio
|
|||
|
||||
auto options = CreateProjectNodeOptions(*builder,
|
||||
nodeOptions,
|
||||
builder->CreateString(filename));
|
||||
builder->CreateString(filename),
|
||||
innerspeed);
|
||||
|
||||
return *(Offset<Table>*)(&options);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue