new a page using UIPageView’s createPage() method, and then add a UIButton to it, with setTouchEnable(true) and setPressedActionEnabled(true), and addTouchEventListener’s callback function doesn’t trigger, but it will scale up when clicking it. It’s strange. Please help! Thanks!
Can you provide some source code of the way you are doing?
Thanks
Huabin
sample code like the following:
var uiLayer = ccs.UILayer.create();
this.addChild(uiLayer);
var pv = ccs.UIPageView.create();
pv.setPosition(cc.p(0, -winSize.height));
pv.setSize(cc.size(winSize.width, winSize.height));
pv.setTouchEnable(false);
var page1 = pv.createPage();
pv.addPage(page1);
var btn = ccs.UIButton.create();
btn.setTouchEnable(true);
btn.loadTextures(s_btn, s_btn, '');
btn.setPressedActionEnabled(true);
btn.setPosition(cc.p(winSize.width / 2, winSize.height / 2));
btn.addTouchEventListener(function (sender, type) {
if (type == ccs.TouchEventType.ended) {
// nothing happen
cc.log('clicked');
}
});
page1.addChild(btn);
uiLayer.addWidget(pv);
Thanks in advance!
Hi,OC.
You must add the target,like:
addTouchEventListener(function(){},this);
Thank you Ma! Made a silly mistake.