Jump to content

Conoonjs+Phaser. Buttons don't work even with CANVAS


altergo
 Share

Recommended Posts

I have the problem with the buttons even in CANVAS mode.

 

Here is my game

 

 var game = new Phaser.Game(width,height, Phaser.CANVAS, 'game');

 

 

And the buttons

 

   for (var i = 0; i < 6; i++) {
 
            if(i%2==0) {
                this.button =  this.add.button((25+90*i), (600), 'buttons', this.actionOnClick, this, 0);
             //   this.button.anchor.setTo(-0.8, 0);
            } else {
                this.button =  this.add.button((25+90*(i-1)), (785), 'buttons', this.actionOnClick, this,  0);
            }
 
            this.ans_text =  this.add.bitmapText(60, -55, 'kuku', this.ans_style, 65);
           // bmpText = this.add.bitmapText
            this.button.addChild(this.ans_text);
 
 
            this.all_buttons.add(this.button);
 
 
        }
 
 
And the Listener
 
 // what happens when i click the button
    actionOnClick: function (button) {
    var log;
    if(button.value==this.char_bubble.char_trans) {
        // right
        blocksound.play();
 
        button.frame=1;
}
 
Nothing happens.
 
I tried to switch of OpenGL on Cocoonjs launcher
 
I use Cocoonjs 2.0.1  and phaser 2.0.4
 
Any suggestions?
 
Link to comment
Share on other sites

well my buttons work very well with cocoonjs and canvas  but i did a little trick i learned here in the forum.. maybe it can help you too..    i edited the phaser source...   forcing canvas is wasn't  enough to solve all the problems i had with cocoonjs -  i needed to edit one line:

 

https://github.com/photonstorm/phaser/blob/dev/src/system/Device.js#L457

 

instead of this line:

 this.webGL = ( function () { try { var canvas = docu.......

write :

this.webGL = false;

i did this and suddenly all problems were gone..  my background images were loading, sounds were there, tilemap layers were there, no sprites suddenly disappear ...  and .. my buttons worked..  

 

 

i used cocoonjs 2.0.0 and phaser 2.0.5

Link to comment
Share on other sites

  • 7 months later...

Would anybody be kind enough to post a simple example of how to setup a button that works in the current version of phaser & cocoonJS (canvas+ mode)?

 

Or point out what I'm doing wrong in the example below?

 

Here's what I have for a button that does not work in canvas+ mode on the iOS testing app (using phaser v2.2.2 & cocoonJS v2.1.1.1):

var button = this.game.add.button(this.game.world.centerX - 100, 215, 'assets', null, this, 'button_play_02.png', 'button_play_01.png', 'button_play_02.png', 'button_play_01.png');button.inputEnabled = true;button.fixedToCamera = true;button.smoothed = false;button.events.onInputOut.add(function() {	console.log('button event onInputOut');}, this);button.events.onInputDown.add(function() {	console.log('button event onInputDown');}, this);
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...