I gave one of my active objects the Bouncing Ball movement in an attempt to make it wrap around the play area.. But it doesn't.. I did a Always, but it doesn't seem to work :S How can you make it do?
Printable View
I gave one of my active objects the Bouncing Ball movement in an attempt to make it wrap around the play area.. But it doesn't.. I did a Always, but it doesn't seem to work :S How can you make it do?
Test for the object to leave the frame then in your actions Movement/Wrap around playfield
Ah, yea there was the event Ive been looking for so many times :D
.. But now, it turns out the movement events of the object is messing it all up. Is there any tutorials about doing this without the built in movement and event method?
Just always set its position to its position mod frame size.Code:Set X Position to X("Ball") mod Frame Width
Set Y Position to Y("Ball") mod Frame Height
Im sorry, what? Mod frame? Are those in the Storyboard Control?
http://www.LB-Stuff.com/MMF2/Modulo.png
The "Frame Width" expression comes from the frame object.
Is Frame object an extension? Cause this is not working for me, when I use the Storyboard Control, which gives exactly the same expression when I choose Frame Width.. But then again, this could be because one of my other events are also using Set X position of Object to xxx, Set Y position of Object to xxx....
The "Storyboard Object" IS the "Frame Object". Most people call it the frame object because it handles things about the frames and not the storyboard...
Yea, thats what I guessed :]
Bah, this project was just supposed to be a very small one-day-created game to relax my brain from my main project.. Yet, Ive had thousands of issues and stuff not working already +_+
Ill just make the player DIE if he tries to move out of the frame.
I know you opted to do something different, but just FYI, LB's method is the best.
Although both MMF's inbuilt wrap function and LB's method don't take into the account the width of the animation, so it's a good idea to include some offsets.
(X("Ball") + (AnimationWidth/2)) mod (Frame Width + AnimationWidth)
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
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?
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_0Quote:
Originally Posted by Ryan
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 :)