OVERLAP EFFECT IN 0:38 of vid?
http://www.youtube.com/watch?v=jFWDqBn_UwU&list=PLD48AE1ABE224F02D&index= 3
I want to do an effect similar to 0:38 of the vid.I want the player to be able to press a button where the lifebar will switch to another lifebar (similar to the effect shown in the vid) with access to a different set of weaponary that the player uses. Basically the player starts off with his whip and item lifebar. Then the player presses a button and the player switches to a lifebar where they are equipped with a gun and can now use different gun ammo for their items. I am still learning mmf2 and would appreciate if someone can explain to me how I can input the effect in the storyboard editor. I have already created the required sprites for the active objects. Please be very specific with me so that I may learn. Thank you for everybody's help.
Re: OVERLAP EFFECT IN 0:38 of vid?
Re: OVERLAP EFFECT IN 0:38 of vid?
The main thing you'd want to understand to be able to do such an effect is the "order" of objects. Objects in the frame are ordered from back to front, and displayed on the screen in that order- each frame, 50 times per second normally, it will draw each object onto the screen, then the next object, and so on. The last one to be drawn will be on top, covering up ones in the back.
Here, you'd want to have an event which changes the order of your HP bars. In addition to either moving them or having the rotation effect as a built-in animation, you'd need to switch which bar is in the front- adjust its order. This can be done from the action in the event editor, Object->Order->Bring to Front. You can find it by clicking in the column for that active object, and it should be one of the functions. There are other order abilities- you can move it to back, or behind/front of a specific other object, or even change which layer it is displayed on. In general, you'd probably want your GUI elements like health bars on a higher layer than the normal gameplay, so they are always displayed in front. So if you had them on their own layer, and swapped their orders, they'd switch which one is in front, but always stay in front of other objects.
Now if you want to create a similar animation, the rotation effect where they switch positions, that gets into more complicated trigonometry- you have to dynamically position the objects at runtime, to move them.
Lets say you have some invisible, different object, in the exact middle of where the two HP and Mana bars should be located. Make sure to put the Hotspot of the image for both bar at the bottom, where you want their base to be 'attached' to. Now, you can position the bars at opposing angles of the object.
To position an object trigonemetrically, your code should look something like this:
Set X position of object to X position of Center + Cos(Angle) * Radius
Set Y position of object to Y position of Center - Sin(Angle) * Radius
Lets say your center object is called "Center", and you use its variable A as a counter, to control how long the rotation should go. Lets say we rotate the angle by 6 degrees every frame for 30 frames- a 180 degree turn. Then we can use flag 0 on this center object to show which bar is on the front. Lets say one is Mana bar, and one is HP bar. The code should resemble something like this:
*Some Action Happens*:
Toggle Flag 0 of Center
Set Variable A of Center to 20
*Is Variable A of Center > 0?*:
Subtract 1 from Variable A of Center
Set Angle of Center to Angle("Center") + 6
*Is Flag 0 of Center On?*:
HP Bar->Order->Bring to Front
*Is Flag 0 of Center Off?*:
Mana Bar->Order->Bring to Front
*Always*:
Set X Position of HP Bar to X("Center") + Cos(Angle("Center"))*16
Set Y Position of HP Bar to Y("Center") - Sin(Angle("Center"))*16
Set X Position of Mana Bar to X("Center") + Cos(Angle("Center") + 180)*16
Set Y Position of Mana Bar to Y("Center") - Sin(Angle("Center") + 180)*16
Hope that helps
Re: OVERLAP EFFECT IN 0:38 of vid?
Thanks PixelThief! I am definetly gonna check this out! I will post a video of my progress when I am done!