Re: How do you wrap an object around the play area?
Im pretty sure LB's method did not work for me, even tho I bet its a super way of wraping it. Its just that it kinda mess up my other events.. Try yourself, Ive uploaded my file here.. Maybe you know a way to solve my other issue aswell:
http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=202944#Post2029 44
Re: How do you wrap an object around the play area?
There were errors in both mine and LB's logic
LB's problem was that he didn't allow for -X and -Y values. This messes up the MOD function.
How do we correct this? We simply add the frame X and frame Y size to the player's X and Y position.
So now, when a player leaves the left side of the screen, his true position is -20 pixels, but our MMF2 code thinks it's actually 780 pixels. We're adding 800 (the width of the frame) to the player's position for this specific calculation.
780 MOD 800 = 780 (800 goes into 780 - 0 times, leaving 780 behind) therefore, this place the player at the right side of the screen, essentially wrapping the player around the screen.
Also my offsets were incorrect, the true code is (drum roll....)
Always Set X Position to: 0-AnimationWidth+(((X( "Hero Player 1" )+AnimationWidth)+FrameXSize+(2*AnimationWidth)) mod (FrameXSize+(2*AnimationWidth)))
Always Set Y position to: 0-AnimationHeight+(((Y( "Hero Player 1" )+AnimationHeight)+FrameYSize+(2*AnimationHeight)) mod (FrameYSize+(2*AnimationHeight)))
But lets not get too caught up on this, basically all were doing is making sure the animation of the player is far enough off screen before we wrap the player to the other side. Because without these offsets, the wrap will occur when the X position is less than 0, which is not neccessarily when your animation has left the screen.
I've uploaded your example with the changes here.
Here's a problem for you to solve though, why does the enemy stop chasing the player after a wrap?
Re: How do you wrap an object around the play area?
Quote:
Originally Posted by Ryan
Here's a problem for you to solve though, why does the enemy stop chasing the player after a wrap?
He doesn't seem to stop chasing, he just goes where the player was before the wrap while your moving, but when you stop it works OK. Un-wrapping yourself by going back the way you came fixes it... 0_0
Re: How do you wrap an object around the play area?
Heh, at my MMF-level, this does not make much sense! However, the result works perfectly! Of course it made a new bug, but thats what updates do. Ill take some time and study what all these new expressions do, and maybe I find something useful! Thanks a lot for all help :)