| 913 | #define ActionDef_Scale Scale::alloc |
| 914 | |
| 915 | static Own<ActionDuration> ActionDef_Frame(String clipStr, float duration) { |
| 916 | auto def = FrameActionDef::create(); |
| 917 | auto [tex, rect] = SharedClipCache.loadTexture(clipStr); |
| 918 | if (!tex) { |
| 919 | Error("invalid texture \"{}\" used for creating frame action.", clipStr.toString()); |
| 920 | return FrameAction::alloc(def); |
| 921 | } |
| 922 | if (rect.getHeight() > rect.getWidth()) { |
| 923 | Error("invalid texture \"%s\" (height > width) used for creating frame action.", clipStr.toString()); |
| 924 | return FrameAction::alloc(def); |
| 925 | } |
| 926 | def->clipStr = clipStr.toString(); |
| 927 | auto totalFrames = s_cast<int>(rect.getWidth() / rect.getHeight()); |
| 928 | for (int i = 0; i < totalFrames; i++) { |
| 929 | def->rects.push_back(New<Rect>(rect.getX() + i * rect.getHeight(), rect.getY(), rect.getHeight(), rect.getHeight())); |
| 930 | } |
| 931 | def->duration = duration; |
| 932 | return FrameAction::alloc(def); |
| 933 | } |
| 934 | |
| 935 | static Own<ActionDuration> ActionDef_Frame(String clipStr, float duration, const std::vector<uint32_t>& frames) { |
| 936 | auto def = FrameActionDef::create(); |