In my game I have a “bullet” object, and for some reason, in the windows build of the game (haven’t tested other builds), it doesn’t spawn properly. I can tell that part of the init() function has been run and that the object has been spawned, since it spawns something using a factory attached to the object, but something must be deleting it and not running the final() code, since it should be getting deleted.
I can’t tell if the issue is just bad code or if I’m accidentally using a debug feature without realising, because I don’t get this issue in the defold editor build
Only part of it? What if you add a print() at the end of the init() function (or even better set a breakpoint using the debugger).
How do you know this? Is it because you never see the object? If so, are you sure it doesn’t spawn behind something (ie it is in the same z-value as a background element or obstacle)?
Ah, sorry for the lack of clarity. In the bullet’s init function, it spawns 4 objects which are offset to it and parented to it, and then fills their sprite with a colour. In the bullet’s final function, it deletes these objects.
In the bundled version, It spawns the 4 objects, but does not parent them to the bullet or change their colour. It also does not delete them at any point in the program.
By looking at the bullet.script, you delete the items after .3 seconds.
Note that the init function is called before the enable, so it’s possible that the game objects are created, and while the game is loading, time has passed and it’s then time to remove them again.
-- init() lifetime==0.3
timer.delay(self.lifetime, false, function() -- After a given time
if not self.hit then
go.delete() -- Delete the object
end
end)
While it did solve my issue with the html and android builds not rendering properly, it appears that the game only seems to fire the bullets correctly in a debug build, so I’m not quite sure where my issue lies.
Again, I have a strong feeling that it’s me accidentally using a debug feature somewhere without realising it, but I could be completely wrong since I don’t know the difference between the debug and release versions. I’ll look into it further