Skip to content

Commit

Permalink
even more fallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
matcool committed Jun 12, 2024
1 parent 9a30ff8 commit a924c79
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Fallback.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <Geode/modify/CCSprite.hpp>
#include <Geode/modify/CCSpriteFrameCache.hpp>

using namespace geode::prelude;

Expand All @@ -24,4 +25,21 @@ class $modify(CCSprite) {
}
return sprite;
}

bool initWithSpriteFrame(CCSpriteFrame* frame) {
if (frame == nullptr) {
return CCSprite::initWithFile("fallback.png"_spr);
}
return CCSprite::initWithSpriteFrame(frame);
}
};

class $modify(CCSpriteFrameCache) {
cocos2d::CCSpriteFrame* spriteFrameByName(char const* name) {
auto* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name);
if (frame == nullptr) {
frame = CCSpriteFrame::create("fallback.png"_spr, {ccp(0, 0), ccp(128, 128)});
}
return frame;
}
};

0 comments on commit a924c79

Please sign in to comment.