Sign in to follow this  
msickle

Is it possible to add tileSprite to physics?

Recommended Posts

I was noodling around and trying to create groups of game objects that had 3 sprites that were cropped from one image.  Similar to a 3-panel round cornered web button.  The reason for this structure is I need variable width with the outer left and right images being fixed.

But I also need it to be a game object with physics and collisions.  I tried adding tileSprite to physics to make this, but it did not work with physics. ("Error: Not a function")

this.blockLeftCap = this.physics.add.tileSprite(100,100,44,43,'button-001');

In the end I can just cut solo images individually, and then add as sprites to physics with no issue:

this.blockLeftCap = this.physics.add.sprite(100,100,'btn-001-cap-left');

 Since I can do this other ways it is no big deal.  But I did like the way tileSprite allowed for easily adjustment of the image cropping.

Just wanted to double check if I was missing something.

Thanks,

Matt

Share this post


Link to post
Share on other sites

Actually animation frames on a sprite also works fine for this.  Many ways to do what I need.

And I checked src and the only GameObject types in arcade physics are Sprites and Images.

Case closed.

Share this post


Link to post
Share on other sites

I found a way to use tileSprite with Arcade physics, i post it here cause it can be usefull for peoples who are searching on the web:

var tileSprite = this.add.tileSprite(x, y, width, height, image);
this.physics.add.existing(tileSprite);

 

 

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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.