Val Variable Keeps Changing Without Any Reassignment
I’ve been working on a basic snake game wirh 3 level. First 2 of them are working completely fine, but the 3rd one is causing trouble. Even though all of the code except for one extra feature (viewModel’s extraWalls variable) is same, idk why this error is occuring only in this one.
java.lang.IllegalStateException: Reading a state that was created after the snapshot was taken or in a snapshot that has not yet been applied
I am working on a very basic snake game using kotlin and jetpack compose. To make it more efficient, I thought of using coroutines, but I keep getting the above mentioned error.
Snake Game Food Updation Working Randomly in ViewModel Coroutine
I’m trynna build a basic snake game for android. Everything is working just fine except for the food updation. It is working randomly, sometimes when you eat it, new food appears, sometimes literally nothing happens, and sometimes, when you pass from right next to the food, it gets considered as eating it, and sometimes the food just doesn’t appear on the screen until a few seconds pass by.