lars

Spine and events

Recommended Posts

Hello 

Im trying to make my spine object interactive:

 

  var player = new game.Spine('mySpine.json');
            //player.hitArea = new game.Rectangle(200, 500);
            player.position.set(300, 800);
            player.interactive = true;

            player.play('idle', true);
            //player.speed = 0.01
            player.addTo(this.stage);


            player.click = function() {
                console.log('check clicked');
            };

That did not work. I tried to put it in a container. That did not help either. It works OK an a sprite object.

Share this post


Link to post
Share on other sites

Hi @lars

I would suggest you to put your Spine object into a container that has custom hitArea defined. Use hit area debugging to visually see where the hit area is and then resize and position it how you want.

var container = new game.Container();
container.interactive = true;
container.hitArea = new game.Rectangle(200, 400);
container.hitArea.x = -100;
container.hitArea.y = -400;

player.addTo(container);

You can find the hit area debugging button from the bottom of the game window.

5ac5130117f00_ScreenShot2018-04-04at21_01_24.png.8c1acd9833a2b79c98ff5abe9077bb5f.png

Share this post


Link to post
Share on other sites

Ok. I tried that to, and I cannot visual see the debug draw in the Panda2 editor when activate #. If I work outside Panda2 editor (Brackets) would i still be possible for me to debug the hit area in a browser like: ?debugDraw=true 

Heres what i tried (I startet with a class, but for now, to test is down to basic :-) :

 

var container = new game.Container();
container.position.set(300, 800);
container.interactive = true;
container.hitArea = new game.Rectangle(237.15, 218.37);
container.hitArea.x = -200;
container.hitArea.y = 218;
container.addTo(this.stage);


var player = new game.Spine('kristian-ronnie.json');
           //player.hitArea = new game.Rectangle(200, 500);
         //player.position.set(300, 800);
         player.play('idle', true);
       
player.addTo(container);
    
        
       container.click = function() {
            console.log('check clicked');
            
        }; 
    }

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.