MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / Animation

Method Animation

source/game/StarAnimation.cpp:11–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9namespace Star {
10
11Animation::Animation(Json config, String const& directory) {
12 m_directory = directory;
13 if (m_directory.empty()) {
14 if (config.isType(Json::Type::String))
15 m_directory = AssetPath::directory(config.toString());
16 else
17 m_directory = "/";
18 }
19 if (config.isNull())
20 config = JsonObject();
21
22 config = Root::singleton().assets()->fetchJson(config);
23
24 m_mode = AnimationModeNames.getLeft(config.getString("mode", "endAndDisappear"));
25 m_base = config.getString("frames", "");
26 // If the base image has no index tag, then assume that the frame is appended
27 // to the end.
28 m_appendFrame = !m_base.contains("<index>");
29 m_frameNumber = config.getInt("frameNumber", 1);
30 m_animationCycle = config.getFloat("animationCycle", 1.0);
31 m_animationTime = m_animationCycle * config.getFloat("loops", 1.0);
32 m_angle = config.getFloat("angle", 0.0f);
33 m_offset = jsonToVec2F(config.get("offset", JsonArray{0.0f, 0.0f}));
34 m_centered = config.getBool("centered", true);
35 m_processing = config.getString("processing", "");
36 m_color = config.opt("color").apply(jsonToColor).value(Color::White);
37 m_variantOffset = Random::randInt(config.getInt("variants", 1) - 1) * m_frameNumber;
38
39 reset();
40}
41
42void Animation::setAngle(float angle) {
43 m_angle = angle;

Callers

nothing calls this directly

Calls 15

singletonClass · 0.85
jsonToVec2FFunction · 0.85
randIntFunction · 0.85
fetchJsonMethod · 0.80
assetsMethod · 0.80
getStringMethod · 0.80
getIntMethod · 0.80
getFloatMethod · 0.80
getBoolMethod · 0.80
emptyMethod · 0.45
isTypeMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected