| 1640 | } |
| 1641 | |
| 1642 | void Sprite::setBatchNode(SpriteBatchNode* spriteBatchNode) |
| 1643 | { |
| 1644 | _batchNode = spriteBatchNode; // weak reference |
| 1645 | |
| 1646 | // self render |
| 1647 | if (!_batchNode) |
| 1648 | { |
| 1649 | if (_renderMode != RenderMode::SLICE9) |
| 1650 | _renderMode = RenderMode::QUAD; |
| 1651 | |
| 1652 | _atlasIndex = INDEX_NOT_INITIALIZED; |
| 1653 | setTextureAtlas(nullptr); |
| 1654 | _recursiveDirty = false; |
| 1655 | setDirty(false); |
| 1656 | |
| 1657 | float x1 = _offsetPosition.x; |
| 1658 | float y1 = _offsetPosition.y; |
| 1659 | float x2 = x1 + _rect.size.width; |
| 1660 | float y2 = y1 + _rect.size.height; |
| 1661 | _quad.bl.vertices.set(x1, y1, 0); |
| 1662 | _quad.br.vertices.set(x2, y1, 0); |
| 1663 | _quad.tl.vertices.set(x1, y2, 0); |
| 1664 | _quad.tr.vertices.set(x2, y2, 0); |
| 1665 | } |
| 1666 | else |
| 1667 | { |
| 1668 | // using batch |
| 1669 | _renderMode = RenderMode::QUAD_BATCHNODE; |
| 1670 | _transformToBatch = Mat4::IDENTITY; |
| 1671 | setTextureAtlas(_batchNode->getTextureAtlas()); // weak ref |
| 1672 | } |
| 1673 | } |
| 1674 | |
| 1675 | // MARK: Texture protocol |
| 1676 | void Sprite::updateBlendFunc() |
no test coverage detected