CCLable Text does not bind with previous scene when scene replacing

DnyaneshDnyanesh Member ✭✭
edited December 2018 in Cross Platform with Xamarin

Hello everyone
I am trying to add CCDrawNode, CClabel for current CCGame its working. but after created 2 separate scenes when i try to replace with previous scene only the CCDrawNode working fine. but about the CClabel, cordinates all changed(with previous scenes), color changed(with previous scenes)
but the Text of CCLabel is showing still of current scene binded Text.

please suggest me if what i m doing wrong?

var testLabel = new CCLabel(string.Format("{0}", this.Title), "fonts/Roboto-Regular_1", 50, CCLabelFormat.SystemFont)
{
Position = new CCPoint(720 / 2, 800),
Opacity = 180,
Color = CCColor3B.Orange,
Text= this.Title
};
layer.AddChild(testLabel );

Answers

  • JuniorJiangJuniorJiang Member, Xamarin Team Xamurai

    Hi @Dnyanesh , when scene replacing , you can post more code about CCLabel doing.

  • DnyaneshDnyanesh Member ✭✭

    Hi @JuniorJiang ;
    please see attched .cs file where i m trying to replace new scene

  • JuniorJiangJuniorJiang Member, Xamarin Team Xamurai
    edited December 2018

    @Dnyanesh Thanking you for posting code.From the codeCreateView() method just need do once about CCLabel's initialization.
    Like this:

    public void CreateView()
    {
    try
    {
    circle = new CCDrawNode();
    if(null = tablename2){
    tablename2 = new CCLabel(string.Format("{0}", this.Title), "Fonts/Roboto-Regular_1", 50, CCLabelFormat.SystemFont)
    {
    Position = new CCPoint(720 / 2, 550),
    Opacity = 180,
    Color = CCColor3B.White,
    };
    layer.AddChild(tablename2);
    circle.DrawCircle(
    new CCPoint(0, 0),
    radius: 100,
    color: CCColor4B.White);
    circle.PositionX = 350;
    circle.PositionY = 800;
    layer.AddChild(circle);
    }           
    if (this.Title == "Screen 1")
    {
    tablename2 set title change
    }
    else
    {
    tablename2 set title change
    }          
    }
    catch (Exception ex)
    {
    ModCommon.ErrorLog("Create View: " + ex.Message);
    }
    }
    
  • DnyaneshDnyanesh Member ✭✭
    edited December 2018

    Thanx @JuniorJiang for your quick reply.
    but this will wont work.
    if you ll see in LoadGame(object sender, EventArgs e) method i m creating a new scene by adding layers which is working fine. now this layers i saved in dictionary by providing this.title key.
    then i moved to main screen from where again i try to open new scene with new page title..which is also working fine.

    the issue is when i just try to replace my current scene with previous layers scene...its not working
    you can check my where i m trying to achieve this.
    public static Dictionary<string, CCLayer> ActiveTableList = new Dictionary<string, CCLayer>();
    ( this is my Dictionary)

    lblObject_tap.Tapped += (s, e) =>
    {

                            if (ModCommon.ActiveTableList.TryGetValue(lblObject.Text, out layer))
                            {
                              CCScene gameScene = new CCScene(nativeGameView);
                  gameScene.AddLayer(layer);
                              nativeGameView.Director.ReplaceScene(gameScene);
                            }
                        };
                        lblObject.GestureRecognizers.Add(lblObject_tap);
    

    but below control always placed on provided cordinates/colors and all.
    circle.DrawCircle(
    new CCPoint(0, 0),
    radius: 100,
    color: CCColor4B.White);
    circle.PositionX = 350;
    circle.PositionY = 800;
    layer.AddChild(circle);

    NOTE: one intresting fact is...even i try to provide hard coded table name after replaced scene it wont work..its not taking

Sign In or Register to comment.