Weird bug when running C++ code on Android devices

  • abhishek
    Likes 0

    Problem Description

    Hi Sonar Systems,
    I recently ported one of my cocos2d-x C++ code from Xcode to android using the build_native.py command.
    The problem is, the game behaves in a weird way – the sprites keep changing their Z positions when i tap on the screen.
    This happens on every Android device i tried (phone, tablet, jelly bean, lollipop, 720p, 1080p).
    I have sent you a video that shows this weird behavior.. please check it out and let me know if you can help me out with this.
    Thanks     

  • Sonar Systems admin
    Likes 0

    How has the design resolution been set?

  • abhishek
    Likes 0

    Hi,
    Thank you for your reply.
    I managed to solve this issue..
    The problem was that when i ported the app to android, the z positions were being messed up when i ran the build on android devices.
    So i simply gave z positions to all sprites and menus manually, so here’s a before and after sample code (might help someone else also)

    BEFORE: (This will draw the scene correctly, but might cause z index problems.. images start overlapping each other)
    this->addChild(sprite_sky);
    this->addChild(sprite_grass);
    this->addChild(sprite_house);

    AFTER: (Works perfect without any issues)
    this->addChild(sprite_sky, 1);
    this->addChild(sprite_grass, 2);
    this->addChild(sprite_house, 3);

     


    This reply has been verified.
  • Sonar Systems admin
    Likes 0

    Great :D

Login to reply