How can i change color in text in a buttom?

function my_button(me,picname,txt,x,y,X,Y,func)
{
         var textButton = new ccui.Button();
         textButton.setTouchEnabled(true);
         //textButton.loadTextures("res/mask.jpg", "res/mask.jpg", "");
         textButton.loadTextures(picname, picname,picname);
         textButton.setTitleText (txt);
         //textButton.LayerColor(cc.color(255, 32, 32, 128));
         textButton.x = x; //size.width / 2;
         textButton.y = y; //size.height / 2;
         textButton.scaleX=X;
         textButton.scaleY=Y;
         textButton.addTouchEventListener(function(sender,type){
          //cc.log("touched2: sender:"+sender+" type:"+type);
          //if(type==0)cc.log("pressed");
          if(type==0)if(typeof func=="function")func();
         },this);
         me.addChild(textButton);
         return textButton
        }

in this function that i made i don’t know what to do to change the color of the text
for now it automatically gives white what can i do pleas help

The answer is right in the API Ref!

https://docs.cocos2d-x.org/api-ref/js/v3x/symbols/ccui.Button.html

1 Like

thank you for the fast replie

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.