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

Method updateColor

core/2d/Sprite.cpp:1500–1533  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1498//
1499
1500void Sprite::updateColor()
1501{
1502 Color4B color4(_displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity);
1503
1504 // special opacity for premultiplied textures
1505 if (_opacityModifyRGB)
1506 {
1507 color4.r *= _displayedOpacity / 255.0f;
1508 color4.g *= _displayedOpacity / 255.0f;
1509 color4.b *= _displayedOpacity / 255.0f;
1510 }
1511
1512 for (unsigned int i = 0; i < _polyInfo.triangles.vertCount; i++)
1513 _polyInfo.triangles.verts[i].colors = color4;
1514
1515 // related to issue #17116
1516 // when switching from Quad to Slice9, the color will be obtained from _quad
1517 // so it is important to update _quad colors as well.
1518 _quad.bl.colors = _quad.tl.colors = _quad.br.colors = _quad.tr.colors = color4;
1519
1520 // renders using batch node
1521 if (_renderMode == RenderMode::QUAD_BATCHNODE)
1522 {
1523 if (_atlasIndex != INDEX_NOT_INITIALIZED)
1524 _textureAtlas->updateQuad(_quad, _atlasIndex);
1525 else
1526 // no need to set it recursively
1527 // update dirty_, don't update recursiveDirty_
1528 setDirty(true);
1529 }
1530
1531 // self render
1532 // do nothing
1533}
1534
1535void Sprite::setOpacityModifyRGB(bool modify)
1536{

Callers

nothing calls this directly

Calls 2

updateQuadMethod · 0.80
setDirtyFunction · 0.70

Tested by

no test coverage detected