Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Sprite Editor Missing Properties #230
The current sprite editor is lacking the "Separate Masks" checkbox as well as a field for "Alpha Threshold" which are saved properties in GMK and GMX. LGM is already loading the properties they are simply not present in the current sprite editor. I have since added them to the sprite editor.
The other issue is regarding the automatic bounding box calculation. It was previously not correctly zero'ing the pixel transparency of the BufferedImage when comparing it with the threshold. The threshold was also not being accounted for in the algorithm, we had it hardcoded to 0. In addition, the comparison was inverted and should have been checking if the alpha is greater than the threshold, not less than.
// the correct comparison is this if (((img.getRGB(i,y2) >> 24) & 0xff) > tolerance) break y2loop; // as opposed to the original version if (img.getRGB(i,y2) >> 24 < tolerance) break y2loop;
These changes make the calculation more compatible with GM8.1 and GMS. The following test case verifies the results, with one exception where GameMaker and LGM will continue to have different results after these changes.
(Left, Top, Right, Bottom)
Then when we set the threshold to 191 LGM will report (0, 0, 0, 0) where GameMaker reports (31, 31, 0, 0) because of a slight anomaly in the algorithm. It does not seem logical that right would be smaller than left, so I believe this is why LGM does it this way and is more correct. If I were doing this as my own game engine I would set the comparison as larger than or equal to the alpha threshold. It does not make logical sense that when the threshold is 255 it would for every sprite always select an inappropriate bounding box (what GM does) or no bounding box at all (what LGM does). However, using this comparison would not be off by one with GM and thus can not be done.
After these changes, all of the bounding boxes for every sprite in the game Croky, posted on the forum, are now calculated the same as GM. This should address many other collision detection issues ENIGMA side in previously tested games.