cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.29k stars 7.05k forks source link

ccui.PageView issue in 3.10 for android (JSB) #16088

Open hemanthunity opened 8 years ago

hemanthunity commented 8 years ago

Hi I would like to use pageView of ccui for android build. it was working fine for HTML5, but when I am trying to build for native android devices using eclipse. pageView.scrollToPage(index); and pageView.getCurPageIndex();

Giving me errors. these 2 methods not supported by JSB.

when I downgrade the framework to 3.9 then its working fine. I also tried with 3.11.1 If I use it then the pageView is working fine but, after moving to last page, and coming back to first page it won't come back first page it stops at 2nd page only. Please look into this issue. and let us know whats the problem.

ricardoquesada commented 8 years ago

thanks. can you post the the code to reproduce it? thanks.

hemanthunity commented 8 years ago

///// Thanks for your reply and Sorry for late reply.. here is my code Tried in 3.10 it throws error, // In 3.11.1, 3.12 it works bur it won't come back to initial index of pageView.

//In 3.9 works fine

this.player1 = new cc.Sprite(res.player1Btn); this.player2 = new cc.Sprite(res.player2Btn); this.navBtnLeft = new cc.MenuItemImage(res.nevBtnPng, res.nevBtnSelPng, function () { this.navLeft() }, this); this.navBtnRight = new cc.MenuItemImage(res.nevBtnPng, res.nevBtnSelPng, function () { this.navRight() }, this);

this.shopView = new ccui.PageView(); this.shopView.setTouchEnabled(true);

    this.page1 = new ccui.Layout();
    this.page1.setSize(this.player1.getContentSize());
    this.page1.addChild(this.player1);

    this.page2 = new ccui.Layout();
    this.page2.setSize(this.player2.getContentSize());
    this.page2.addChild(this.player2);

    this.shopView.setSize(cc.size(cc.winSize.width * 0.75, this.page1._getHeight()));
    this.player1.setPosition(this.shopView.getSize().width * 0.5, this.shopView.getSize().height * 0.5);
    this.player2.setPosition(this.shopView.getSize().width * 0.5, this.shopView.getSize().height * 0.5);

    this.shopView.addPage(this.page1);
    this.shopView.addPage(this.page2);

    this.addChild(this.shopView, 6);
    this.shopView.scrollToPage(0);
    this.shopView.setCustomScrollThreshold(0.5); 

cc.log(" **"+this.shopView.getCurPageIndex()); // Here I am getting error in 3.10

/**\ And these below functions are left arrow and right arrow button functionalitities navLeft: function () {

    var pgId = this.shopView.getCurPageIndex();
this.shopView.scrollToPage(parseInt(pgId) - 1);

},
navRight: function ()
{
      var pgId = this.shopView.getCurPageIndex();
    this.shopView.scrollToPage(parseInt(pgId) + 1);

},

-Thanks

hemanthunity commented 8 years ago

Hi, Thanks for reply, I have posted the code on https://github.com/cocos2d/cocos2d-x/issues/16088 .. Please look into it and help me to solve this issue.

Thanks Hemanth

On Tue, Jul 12, 2016 at 2:56 AM, Ricardo Quesada notifications@github.com wrote:

thanks. can you post the the code to reproduce it? thanks.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cocos2d/cocos2d-x/issues/16088#issuecomment-231870380, or mute the thread https://github.com/notifications/unsubscribe/ATc3ZhmZNhe04-LfDR2aRDK3OG3enbT_ks5qUrUegaJpZM4JJMuN .