I trying to use @darzu’s amazing Sprite Grid extension in a “merge type” game. Before, moving the cursor worked perfectly fine. When I failed to make the cursor selection code, I removed it but now even moving the cursor doesn’t work. I get an error saying Program Error: Cannot read property of 'vtable' of null. I am very confused because I looked thought grid.ts but searching for vtable returns nothing. There is literally no possible way to access an undefined variable in my code to my knowledge.
Here is the link:
You were placing both cursors at (5,10) so the second cursor was taking the place of the first one and kicking it off the grid. Then when you try to do a grid move on the first one it was erroring (in a very inconvenient way) because the first one isn’t on the grid anymore.
Sprite Grid needs to be updated to support multiple sprites per cell. How I worked around this was by not having the cursors be part of the grid… which is annoying.
Oh also you don’t need to call “snap” before “place”. I noticed you did that a few times. “grid place” should add items to the grid correctly. “snap” just internally calls “grid place” at the current location of the sprite.
Ah, that makes more sense.
Thank you so much!
I’ll probably just move the selected cursor to 0, 0 and teleport it over to the cursor’s last position probably ghost it or swomething like that, as you did.
Oh also you don’t need to call “snap” before “place”. I noticed you did that a few times. “grid place” should add items to the grid correctly. “snap” just internally calls “grid place” at the current location of the sprite.
I honestly thought that would initialise something and if I didn’t do it, it would probably throw some not defined error or something like that.
Thank you so much for making this extension. I wish I had when I made Crossy Roads 2
It’s possible that in long running games there might be issues with the multiple sprites per location. To fix that I’ll just need to run some periodic cleanup code. So if you see things slowing down or get other issues, let me know!