This is driving me bonkers so hopefully a kind soul will be interested in a small puzzle to solve or explain. I have a little capx project. The idea is to draw platforms on the screen using a gray box sprite called plat. its on a 32x32 grid.
when run, the game will spawn better looking sprites called plat_skin on top of the plat sprites, and pick different frames based on their positions (left end, center or right end. this way I could quickly map out platforms by just stretching the play sprite about the layout, and the logic will build the rest.
The left end sprite works, but not the right.
So... if a plat_skin is spawned and has no platform under it, its deleted, making a gap. It should then pick the previous plat_skin, and change the animation frame to 2 (which is the far right image for my platforms).
I've tried picking by instance, iid and uid, and it seems to just not do it. I cant see a problem with the logic.
Heres the capx: https://www.dropbox.com/s/4auc19xpddvq40y/PlatformLevelEngine.capx?dl=0
The issue is with event 6 in my event sheet, there should be an screenshot below. I just cant see the problem.
I think this is something to do with the engine where if you start creating instances within a tick, you can't pick them until next tick. For example if you change the condition in event 6 to plat_skin.UID=64 change anim, it will not change the anim, but if you pull this condition out of the loop and try it, then the instance can be picked and changes anim frame to 2, so this looks like a case of you cannot pick those created instances within the loop and must try a different approach. A possible approach could be to store the last UID of all the relevant plat_anim objects and then change them all together later on?
Hi, I made you another system that work just like you want with less events and variables :
Instead of spawing sprites all over the layout and delete them it spaws it directly on the grey plateforms, then it triggers a function to update the sprites frame;
I created a family with the sprite inside to check if there is a tile on left or right of the sprite by overlapping offset, then it can change the frame accordingly ~
(Note that the "Wait 0 second" is important so the game has time to spawn the sprites before it triggers the function)
Edit : I made a little change to the first event that allows you to change the angle of the grey plats and spawn the sprites accordingly to the angle :
Develop games in your browser. Powerful, performant & highly capable.
WOW Tomycase, excellent solution.
I'll have a go tonight. Spawning on the plats themselves.. wish I'd thought of that!
No problem, tell me if you have any issue when you try it ^^
Hi, That work well. Very elegent logic.