0

I am a complete novice in createjs and wanted some guidance over this topic of collision detection. I have created some text objects using font awesome using a loop. Next I saved them in variable objx as id along with updating its position coordinates(x,y) in it. And here is the code for collision detection:

createjs.Ticker.addEventListener("tick", function(){
    var jx,jy,jt,t;
        for(var i = 0 ; i < objx.length-1 ; i++)objx[i].id.color="#8B0000";
        for(var i = 0 ; i < objx.length-1 ; i++){
            x = objx[i].x;y = objx[i].y;t = objx[i].id;
            for(var j = i+1 ; j < objx.length-1 ; j++){
                jx = objx[j].x;jy = objx[j].y;
                if(x+t.getMeasuredWidth()>=jx && y+t.getMeasuredHeight()>=jy )
                {
                    jt = objx[j].id;
                    jt.color="#0000CD";
                    t.color="#0000CD";
                }
            }
        }
        stage.update();});
  }


}

The initial part of tweenjs is working fine. I just wanted the collision to occur in such a way such that color of text changes only on collision and should be back to initial color after collision. This generates an image which is similar to : enter image description here

1 Answer 1

1

This is very good for EaselJS collision detection. Collision Detection

You could use either pixel perfect detection or The bounding box collision detection.

Sign up to request clarification or add additional context in comments.

2 Comments

I just started using it on a project and it is great!
Cool.If you want any more techniques contact with me . I know abount AABB colision and rotated rectangle collision. Also dont for get to tick the answer if it works !!! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.