Alexandre58

Sprite rotation with collision PIXIJS

Recommended Posts

Hello, 

I have a problem with my pixiJS App, i have many sprites that I can move in my scene and my goal and create a plan with collisions between sprites, for that I use the bump plugin and the rectangleCollision fuuntion :https://github.com/kittykatattack/bump/

 

let collision = b.rectangleCollision(selectCont,c2,true,false,true);

It's works (the middle case on the pic)if my sprite have no rotation but if i want to apply a rotation on my sprite the collisions doesen't work (left and right case in the pic).

I thnik it's a problem with sprite bounds but i have no idea.

Can you help me please ? 😀

Capture.PNG

Share this post


Link to post
Share on other sites

Sorryt i don't have write all my script 

I have an array with all my sprite and i have a function when i do a right click on sprite it apply a rotation and when i wan't to apply my rotation it's work but my collision is not correct :(

for (var j = 0j < cont.lengthj++) {
        var c2 = cont[j];
 
        b.contain(c2, {x: 0y: 0width: 2400height: 1800}, true);
        if(selectCont!=c2){
            if(activeCollision == true){
                let collision = b.hit(selectCont,c2,endCollision,false,true);
            }
        }
    }
//function to apply a rotation to sprite
function rotate(){
    this.rotation -= Math.PI/4;
}

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.