The "Lookup Variables" idea is interesting, but setting it up must be a chore.
Here are my tips:
1. In all my big projects, I create a AudioPlay function and call it whenever I need to play a sound, instead of using the "Play" action directly. This makes it easy to modify the entire sound system later. For example, you can quickly implement a global volume setting or adjust how audio tags are named.
2. Similarly, I use a single _LOG function for console logging. This allows me to disable all logs before publishing the game.
3. Another logging tip: right-clicking anywhere prints all objects under mouse cursor to the console. This is incredibly useful in large games with thousands of objects, many of which are hidden. I used to waste a lot of time manually searching for the right instance in the debugger.
Here is the code:
const excludeFamilies = true;
const results = []; // Collect results in an array
for (const objectTypeName in runtime.objects) {
const allInstances = runtime.objects[objectTypeName].getAllInstances();
const filteredInstances = allInstances.filter((e) => e.layer && e.layer.name);
var idx=0;
for(var i=0; i<filteredInstances.length; i++) {
const instance = filteredInstances[i];
const layerIndex = instance.layer.index;
const x = runtime.objects.Mouse.getMouseX(layerIndex);
const y = runtime.objects.Mouse.getMouseY(layerIndex);
const left = instance.getBoundingBox().left;
const top = instance.getBoundingBox().top;
const right = instance.getBoundingBox().right;
const bottom = instance.getBoundingBox().bottom;
// Check if the mouse cursor is within the instance's bounding box
// If excludeFamilies=true, duplicate UIDs will be skipped
if (excludeFamilies===false || !results.some(record => record.UID === instance.uid)) {
if (x >= left && x <= right && y >= top && y <= bottom) {
// console.log(`${objectTypeName}\t\tLayer: ${instance.layer.name},\t\tUID: ${instance.uid}`);
results.push({
Object: objectTypeName,
Layer: instance.layer.name,
UID: instance.uid,
IID: idx,
Visible: instance.isVisible,
Collisions: instance.isCollisionEnabled || "",
Animation: (instance.animation ? (instance.animation.name+":"+instance.animationFrame) : "")
});
}
}
idx++;
}
}
console.table(results);
4. My final logging tip: I created an addon (which, unfortunately, won't work with SDK2) that adds event sheet names and event numbers to all log messages. It also allows to disable logging in the entire project. I wish the Browser object had built-in settings for this.