Skip to content

Commit 58077ed

Browse files
newnonminggo
authored andcommitted
Add blend function to Text (#18631)
1 parent 677b5a1 commit 58077ed

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

cocos/ui/UIText.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,16 @@ Sprite * Text::getLetter(int lettetIndex)
409409
return _labelRenderer->getLetter(lettetIndex);
410410
}
411411

412+
void Text::setBlendFunc(const BlendFunc &blendFunc)
413+
{
414+
_labelRenderer->setBlendFunc(blendFunc);
415+
}
416+
417+
const BlendFunc& Text::getBlendFunc() const
418+
{
419+
return _labelRenderer->getBlendFunc();
420+
}
421+
412422
Widget* Text::createCloneInstance()
413423
{
414424
return Text::create();

cocos/ui/UIText.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace ui {
4444
/**
4545
* For creating a system font or a TTF font Text
4646
*/
47-
class CC_GUI_DLL Text : public Widget
47+
class CC_GUI_DLL Text : public Widget, public cocos2d::BlendProtocol
4848
{
4949

5050
DECLARE_CLASS_GUI_INFO
@@ -329,6 +329,24 @@ class CC_GUI_DLL Text : public Widget
329329
* @warning No support system font.
330330
*/
331331
virtual Sprite * getLetter(int lettetIndex);
332+
333+
/**
334+
* Sets the source blending function.
335+
*
336+
* @param blendFunc A structure with source and destination factor to specify pixel arithmetic. e.g. {GL_ONE, GL_ONE}, {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}.
337+
* @js NA
338+
* @lua NA
339+
*/
340+
virtual void setBlendFunc(const BlendFunc &blendFunc) override;
341+
342+
/**
343+
* Returns the blending function that is currently being used.
344+
*
345+
* @return A BlendFunc structure with source and destination factor which specified pixel arithmetic.
346+
* @js NA
347+
* @lua NA
348+
*/
349+
virtual const BlendFunc &getBlendFunc() const override;
332350

333351
CC_CONSTRUCTOR_ACCESS:
334352
virtual bool init() override;

0 commit comments

Comments
 (0)