You could define your own names for the collision categories, to make your code more readable for you.
For this, a singleton is the best approach, e.g. like this:
Create a new qml file CollisionCategories.qml
pragma Singleton
import QtQuick 2.0
import Felgo 3.0
Item {
property int ship: Circle.Category1
property int other: Circle.Category2
}
In order to register this type as a singleton, you must additionally create a file with the name qmldir in the same folder, and add this content:
singleton ColliderCategories 1.0 ColliderCategories.qml
Then you can use your own categories like this:
CircleCollider {
collidesWith: ColliderCategories.ship
}
NOTE: One thing to mention here: If the ColliderCategories.qml file is in the same folder as the qml file where you are using it, you need to add this import to the file where using the categories:
import "."
This signals the qml engine to look through the current directory to see if any qmldir files are present to register them. If you do not import the folder with the qmldir file, you will see an error like this “ReferenceError: ColliderCategories is not defined”
Cheers,
Alex