Hello all! I’m one of those guys coming in hot from the Humble Bundle. I’m not very interested in the No-Code approach, instead I like me some JavaScript. There’s not a heck of a lotta documentation so I’m struggling. At one point I kinda thought I could always use the No Code to do what I want and look at the JavaScript in the debugger and steal that code if I’m in trouble, but that code is usually kinda mangled and beyond my comprehension!
Um, so I have an Enemy1 and a CoconutDrop object that I wanna check collision for - and it works good in the No-Code. This is generated JavaScript
gdjs.copyArray(runtimeScene.getObjects(“CoconutDrop”), gdjs.Level_321Code.GDCoconutDropObjects1);
gdjs.copyArray(runtimeScene.getObjects(“Enemy1”), gdjs.Level_321Code.GDEnemy1Objects1);
gdjs.copyArray
gdjs.Level_321Code.condition0IsTrue_0.val = false;
{
gdjs.Level_321Code.condition0IsTrue_0.val = gdjs.evtTools.object.hitBoxesCollisionTest(gdjs.Level_321Code.mapOfGDgdjs_46Level_95321Code_46GDCoconutDropObjects1Objects, gdjs.Level_321Code.mapOfGDgdjs_46Level_95321Code_46GDEnemy1Objects1Objects, false, runtimeScene, false);
}if (gdjs.Level_321Code.condition0IsTrue_0.val) {
{gdjs.evtTools.sound.playSound(runtimeScene, “Assets\SFX\SoundFX\BigShot.wav”, false, 100, 1);
}} */
I’m OFC just playing a sound on impact. If I paste this code I get errors and I assume its because of the mangled/generated variable names, so I’ve taken my limited JavaScript knowledge and tried to simplify it to the following:
var Hit = gdjs.evtTools.object.hitBoxesCollisionTest( runtimeScene.getObjects(“CoconutDrop”), runtimeScene.getObjects(“Enemy1”), false, runtimeScene, false );
if( Hit ) console.log(“Hit”);
But I never get a hit. I think I’m not understanding the array that I’m (not?) passing into the collision tester().
Anyone have any ideas?
Thanks in advance!
Lawrence