MCPcopy Create free account
hub / github.com/axmolengine/axmol / initWithImageData

Method initWithImageData

core/2d/Sprite.cpp:320–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

318}
319
320bool Sprite::initWithImageData(const Data& imageData, std::string_view key)
321{
322 if (imageData.isNull() || key.empty())
323 {
324 AXLOGD("Call Sprite::initWithImageData empty data or blank key.");
325 return false;
326 }
327
328 //_fileName = filename;
329
330 Texture2D *texture = _director->getTextureCache()->addImage(imageData, key);
331
332 if (texture)
333 {
334 Rect rect = Rect::ZERO;
335 rect.size = texture->getContentSize();
336 return initWithTexture(texture, rect);
337 }
338
339 // don't release here.
340 // when load texture failed, it's better to get a "transparent" sprite then a crashed program
341 // this->release();
342 return false;
343}
344
345Sprite::Sprite()
346{

Callers 11

initWithDictionaryMethod · 0.45
getDefaultTextureFunction · 0.45
createMethod · 0.45
addImageMethod · 0.45
createStatsLabelMethod · 0.45
createSpriteFromBase64Function · 0.45
initMethod · 0.45
onEnterMethod · 0.45
onEnterMethod · 0.45
LoadMethod · 0.45

Calls 5

isNullMethod · 0.80
getTextureCacheMethod · 0.80
emptyMethod · 0.45
addImageMethod · 0.45
getContentSizeMethod · 0.45

Tested by 2

onEnterMethod · 0.36
onEnterMethod · 0.36