@efares wrote:
I am making a UI Button like this
// Instructions Button var instructionsButton = new ccui.Button(); instructionsButton.loadTextures("instructions_n.png", "instructions_s.png", "", ccui.Widget.PLIST_TEXTURE); instructionsButton.setTouchEnabled(true); instructionsButton.addTouchEventListener(this.onInstruction, this); instructionsButton.setPosition(cc.p(x, y)); this.addChild(instructionsButton);
And adding an image that contains some instructions like this
// Instructions Page this.instructionsPage = new ccui.Button(); this.instructionsPage.loadTextures(res.instructions_png, res.instructions_png); this.instructionsPage.setTouchEnabled(true); this.instructionsPage.addTouchEventListener(this.onCloseInstructions, this); this.instructionsPage.setPosition(cc.p(x, y));
And I only want to show the Instruction Page (add it as a child) when the UI Button is touched so I did this
// Instruction button is selected onInstruction: function (sender, type) { switch (type) { case ccui.Widget.TOUCH_BEGAN: break; case ccui.Widget.TOUCH_MOVED: break; case ccui.Widget.TOUCH_ENDED: this.addChild(this.instructionsPage); break; case ccui.Widget.TOUCH_CANCELLED: break; } }
This works fine when I test it on my laptop browser but the instructionsPage does not show when I run it on my Android device.
I am using Cocos2d-x JS v3.7 on a Mac and testing on Chrome browser.
Posts: 1
Participants: 1