• Gamedev
  • How can I emulate a Copy's collision boundaries?

I'm trying to test out vector graphics using PIXI.Graphics for a copy/template. Because I'm doing it like this I don't have a texture or collision mask set for the copy. Normally I would have a sprite assigned to the copy so that it would respond to things such as ct.touch.collide but I won't have that in this case. Is there a way I can create the collision mask myself in the copy's code? Something as simple as a rectangular collision mask will do.

firecakes There is. ct.place reads a property shape from every copy to convert it into a collision shape. If you would like to create a rectangular collision shape, you would do something like this in copy's OnCreate:

this.shape = {
  type: 'rect',
  top: 10,
  left: 20,
  bottom: 10,
  right: 20
};

This would produce a centered rectangular mask of 40x20 pixels. You can derive the process of how ct.place reads collision masks if you look into the getSSCDShape method in the ct.place's index.js file.

    Write a Reply...