Jump to content

Gamecontroller help [1.1.5]


Heppell08
 Share

Recommended Posts

I've looked at gamecontroller js and i'm pretty happy with how it works, the only problem i have is using it to call a function.

I has the touchmove and the a jump button has a touchstart function.

My problem is that my jump is very specific. Not for just going up or down but it depends on what the gravity is doing and there the player is and what the player is 'touching'. 

I tried to copy the update code i use for jumping and placing it in a simple function then calling it on the jump button from the gamecontrollers touchscreen button provided.

Problem is i get a weird error saying that:

 

Uncaught TypeError: Object #<t> has no method 'jump' Game.js:297

 

Now on line 297 i have:

GameController.init(         {         left:         {            type: 'joystick',            touchMove: function(joystick_details) {                this.input.joystickLeft = joystick_details;            },            touchEnd: function() {                this.input.joystickLeft = null;            }        },             right:             {                 position:                 {                     right: '5%'                 },             type: 'buttons',             buttons: [            {                 label: 'jump', fontSize: 13, touchStart: function()                 {                    this.jump();                }             },             false, false, false            ]         }    } );

So in the code above i put it as the numbers are in my game and you see i just has this.jump();

Now i battled last night with this but was too late to keep testing with it and didnt post this last last night.

I also tried putting just jump(); but its not defined, i tried this.player.jump(); but cant call jump. I'm using a state set up and not a single js file. 

Any help/exmaple etc are highly appreciated.

 

Thanks :)

 

Link to comment
Share on other sites

maybe this helps:

GameController.init({                            left: {                                 type:'joystick',                                 joystick: {                                     touchMove: function(details){                                                                     if (details.dx < -5){left=true;}                                                                     else if (details.dx > 5){right=true;}                                                                     else {left=false;right=false;}                                                                     if (details.dy < -5){ duck=true;}                                                                    else{duck=false;}                                                                     renderdetailsx=details.dx;                                                                     renderdetailsy=details.dy;                                                                 },                                     touchEnd: function() {left=false;right=false;duck=false;}                                 }                            },                            right: {                                 position: {right: 60,bottom: 60},                                 type: 'buttons',                                 buttons: [                                {                                     label: 'B',                                    fontSize: 13,                                    touchStart: function() { jump=true;},                                    touchEnd: function() { jump=false; }                                 },                                 {                                     label: 'A',                                    fontSize: 13,                                    touchStart: function() { fire=true;},                                    touchEnd: function() { fire=false; }                                },                                false, false                                ]                            }, });

and in the update function i just check the vars (up,down,left,right,jump,fire) and do whatever is needed...

 

 

 

and if you decide to trash gamecontroller js (because of minor bugs with the buttons and low performance ^^):

 

http://www.html5gamedevs.com/topic/1813-the-monthly-phaser-examples-contest/?p=27173

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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