I keep getting this red screen about multitouch “touch has ended” being undefined
If you’re using JavaScript, verify your code. Otherwise, this might be an issue with GDevelop - consider reporting a bug. Full error is: Cannot read properties of undefined (reading ‘justEnded’)
TypeError: Cannot read properties of undefined (reading ‘justEnded’)
at o.hasTouchEnded (http:/inputmanager.js:1:2989)
at n.hasTouchEnded (http:/events-tools/inputtools.js:1:5407)
at gdjs.evtsExt__critter__touchMarker.touchMarker.doStepPreEventsContext.eventsList0 (http:/gdjs-evtsext__critter__touchmarker.js:197:41)
at gdjs.evtsExt__critter__touchMarker.touchMarker.doStepPreEvents (http:/gdjs-evtsext__critter__touchmarker.js:275:81)
at touchMarker.stepPreEvents (http:/runtimebehavior.js:1:882)
at s.stepBehaviorsPreEvents (http:/runtimeobject.js:1:15265)
at l._updateObjectsPreEvents (http:/CustomRuntimeObjectInstanceContainer.js:1:2437)
at device.update (http:/CustomRuntimeObject.js:1:2186)
at c._updateObjectsPreEvents (http:/RuntimeInstanceContainer.js:1:4554)
at c.renderAndStep (http:/runtimescene.js:1:4923)
I was using minimal events that weren’t optimal but I didn’t want to create a bunch of events. I don’t recommend my method. It was strictly for testing.
Again. These events are flawed and incomplete because it only saved the most recent single, touch ID and it didn’t remove the ID when the touch was released. I had to tap the screen quickly with alternating fingers. It seems to be related to checking for invalid IDs.
I tested the Multitouch example project and it works fine. I modified my quick test project so it didn’t check for previous IDs.
Again, I realize these events wouldn’t capture all of the mouse touches. This was just for testing. It prevented invalid IDs from being tested. I was unable to get it to crash using these events.
I’m not having the problem anymore, I’ll post screenshots later, but all my code is spread in functions inside behaviours and custom objects. The problem was fixed when I stopped running the deletion of the “Touch” object at preStep events and switched to running that on postStep events, now I can tap the screen like crazy and get no error.
(It never crashed on desktop, only on phone web preview)
I’m glad it’s working. It sounds like for you it might have been a timing issue. My testing seems to have used invalid touch IDs. Although, I couldn’t recreate it by using a fixed number instead of a variable.
Either way, it shouldn’t be causing a critical error. I hope someone from Gdevelop sees your post and looks into it.
This will probably be my final test. I created events that added objects each time a new touch happened. I used the objects to test for the touch ID had ended. It didn’t crash until after I had really gone wild with my finger tapping.
These are the IDs it was testing for, each one represents an object with a previous ID.
So, it doesn’t seem like it’s just that the ID is invalid but maybe there’s a timing issue or something weird happens with multiple quick simultaneous touch changes.
This is my full error.
A crash or error happened in the game.
If you're using JavaScript, verify your code. Otherwise, this might be an issue with GDevelop - consider reporting a bug. Full error is: Cannot read properties of undefined (reading 'justEnded')
TypeError: Cannot read properties of undefined (reading 'justEnded')
at o.hasTouchEnded (https://resources.gdevelop-app.com/GDJS-5.4.214/Runtime/inputmanager.js:1:2989)
at n.hasTouchEnded (https://resources.gdevelop-app.com/GDJS-5.4.214/Runtime/events-tools/inputtools.js:1:5407)
at gdjs.Untitled_32sceneCode.eventsList0 (https://game-previews.gdevelop.io/1728177969893-628670/code0.js?gdCacheBurst=1601116901:62:41)
at gdjs.Untitled_32sceneCode.eventsList3 (https://game-previews.gdevelop.io/1728177969893-628670/code0.js?gdCacheBurst=1601116901:144:27)
at gdjs.Untitled_32sceneCode.func [as _eventsFunction] (https://game-previews.gdevelop.io/1728177969893-628670/code0.js?gdCacheBurst=1601116901:293:27)
at c.renderAndStep (https://resources.gdevelop-app.com/GDJS-5.4.214/Runtime/runtimescene.js:1:5343)
at h.step (https://resources.gdevelop-app.com/GDJS-5.4.214/Runtime/scenestack.js:1:674)
at https://resources.gdevelop-app.com/GDJS-5.4.214/Runtime/runtimegame.js:1:8843
at i (https://resources.gdevelop-app.com/GDJS-5.4.214/Runtime/pixi-renderers/runtimegame-pixi-renderer.js:1:10057)
I was deleting the objects when the touch ends. it probably was too much for my android devices to do everything in preStep, because taking that last step to postStep fixed it.
I wasn’t using an extension or behavior. I was using a regular scene event sheet. In your case, it sounds like maybe timing or sequence of events. I think there’s something not happening immediately or maybe it’s when there are multiple touch changes. IDK.