Level Screen like Angry Birds or Cut the rope with 3 Stars

  • koko82
    Likes 0

    Problem Description

    Hi All,

    Was wandering when you make a 18 to 21 levels for sprites and including stars. How would it be the best be performed. Would you loop 3 rows for each level sprite or would you use 3 rows of Menu items maybe. I am looking for which way is best, doing manual loops to present the levels 1-24 on the page or if there is something in cocos2dx that is better to perform the level screen (optimization). Any help or guidence would be appreciated.

    Also when you add 3 stars would you just use game data from Usedefault then select which sprite of stars to put up? It would seem each time the level page is put up it would have to go through the loop and data. Anyway of decreasing that processing as well?

    koko82


  • Sonar Systems admin
    Likes 0

    3 rows will work great.

     

    Regarding the processing, due to the screen its on the processing won’t be an issue.

  • koko82
    Likes 0

    It works well once you add the padding. But I want to find out location of the menuimage elements, but it turns up as 0,0 when you try grab location points.

    Is there a way of doing it?

  • Sonar Systems admin
    Likes 0

    What exact method are you using?

  • koko82
    Likes 1

    For example 

     

    L1 = MenuItemImage::create("A7.png", "A7.png", CC_CALLBACK_1( C1LevelSelector::Level1, this));
    L1->setTag(1);
    
    auto menu1 = Menu::create (L1,nullptr);
      
    menu1->setPosition( Point( visibleSize.width / 2 + origin.x, visibleSize.height / 1.2 + origin.y))
    log("Position Y = %f", menu1->getChildByTag(1)->getPositionY());
    log("Position X = %f", menu1->getChildByTag(1)->getPositionX());
    
    this->addChild(menu1, 1);

    From log outputs :

    Position Y = 0.000000

    Position X = -450.000000

    which is not the right co-ordinates of that image?


  • Sonar Systems admin
    Likes 0

    Instead of doing this, set the menus position to (0,0) and set the position of each menu item manually, this is more work but will allow you to access the position.

     

    We briefly discuss this in the following video http://www.sonarlearning.co.uk/coursepage.php?topic=game&course=cocos2d-x-v3&videoindex=46#46

  • koko82
    Likes 0

    Ok thanks, was hoping to use the automatic menu as it will resize it for different devices automatically. The 3 rows look really good and aligned, not sure where they are positioned though! Guess will need to debug it via psender?

  • koko82
    Likes 0

    Annoying the menu swallows the listener. So unable to perform debug for the positions already :(

       log("onTouchBegan x = %f, y = %f", touch->getLocation().x, touch->getLocation().y);

     

  • Sonar Systems admin
    Likes 0

    ?????     

  • koko82
    Likes 1

    I am trying to extract the current locations of the menu items. But when I set up a listener to click and find location of the menu item it doesnt do anything. When I disable the menu it works, but then I have lost the locations of the current menu items.

  • koko82
    Likes 1

    I’ve sorted it by doing it manually and using the visiblesize so will help when resizing on other devices and much better than using padding! Many thanks, very happy!

  • Sonar Systems admin
    Likes 0

    Great to hear :D

Login to reply