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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.