How to carry information across frames
just wondering, how could you go about making things such as weapons, powerups, etc carry over to additional frames? for example, lets say you are making a mario game, your start of frame by default will have him small, but when you clear a stage you keep the current powerup you acquire throughout the previous stage. how would i go about doing something to that effect?
Re: How to carry information across frames
It depends; how are you storing the existence of the powerup?
Is the info stored in an array, in a player's alterable value? Does the powerup 'know' itself, if it is currently being held by the player?
There are lots of solutions depending upon how you have coded the information that you wish to carry over?
One solution would be to make you player global; that means that any alterable variables stored in it are remembered from frame to frame.
Re: How to carry information across frames
sorry for the confusion. i have all the powerups linked to alterable values. i didnt know about the global value thing. would i set that just for my character or does that go for all the items associated with the powerups as well?
Re: How to carry information across frames
Personally, I'm a big fan of Global Values, as they are the easiest to use.
On the application view click the application symbol, then flick through the tabs to Global Values.
Click new, then rename Global Value A to something like "Powerup".
Then, change your coding so that:
If "Powerup" = 0;
-Player set animation to "Little"
If "Powerup" = 1;
-Player set animation to "Big"
If "Powerup" = 2;
-Player set animation to "Giant"
etc.
Global Values are used throughout the entire Application, and just like Alterable Values (which are local ones for actives), you can have 26 different values.
Re: How to carry information across frames
thanks for the input guys! i didnt know that about global values! so why wouldnt people use them as opposed to alterable values? seems like they are WAY more helpful. thanks again! :grin:
Re: How to carry information across frames
I think that all the time.
People around here are so hung up on Arrays and the like that they underestimate simple things that MMF2 does natively.
If you don't want to undo all that hard work setting Alt.Vals, do this:
End of Frame
-Set Global Value A to Player Alterable Value A
then on a new frame
Start of Frame
-Set Player Alt Val to Global Value A
Bit more work, but could be less of a hassle. It's better to recode everything though and do that right the way through.
Re: How to carry information across frames
your right, but i need to experiment anyway lol. yeah im with, you seems like this could be alot less hassle this way. thanks again!
Re: How to carry information across frames
You could also make your player object global in its properties. Then all its alterable values will be carried between frames.
Re: How to carry information across frames
Thanks Dynasoft! this would be alot more helpful at the moment considering i have all the events setup to alterable values! im actually making a castlevania but i just used the mario as a reference. the main thing i was hoping to achieve was to let the subweapons carry over to other frames upon pickup. like if you pick up the dagger, once you cross over to the next frame you still have the dagger.
Re: How to carry information across frames
Quote:
Originally Posted by Warmachine
thanks for the input guys! i didnt know that about global values! so why wouldnt people use them as opposed to alterable values?
Each tool has its purpose!
An alterable value 'belongs' to an object, whereas a global value 'belongs' to the application.
If you want an object to have alterable values that are carried from frame to frame along with the object, then you make the object a "global object", which means that it exists across the whole application, not just the current frame. So, if an object had an alterable value "Power Up=1" at the 'end' of Frame 1, it would still hold that value if it was used in Frame 2.
This would enable you to have hundreds of 'enemies' which each have their own alterable values (e.g. health). Global values would not be suitable for this purpose (unless, perhaps, you had one or two enemies).
I find the easiest way to use an object in another frame is to create and display the new frame and then drag the glboal object into the new frame from the list of objects shown in the Workspace toolbar. It will then be available along with all its alterable values in the new frame (and any other frame you copy it to).
My final tip is to rename alterable and global values to give them sensible names; I didn't know that this could be done for months after I started using MMF2! If you don't know how to do it, then right click on the variable name (e.g. alterable value A) and select rename.
Re: How to carry information across frames
Also:
Don't forget to reset anything global at the start or end of the game. Don't want your player starting level 1 with a super-power-up just because he had it when he got a game over...
Re: How to carry information across frames
lol yeah i caught onto being able to change the names of the values. for awhile i was like "wtf?" :D i see your meaning about making the object global. the way im understanding is, you make your character, enemy, etc with the alterable values and anything that will be effected later should be made global....i'll have to play around with that. Thanks again!
Re: How to carry information across frames
Quote:
Originally Posted by Dynasoft
Also:
Don't forget to reset anything global at the start or end of the game. Don't want your player starting level 1 with a super-power-up just because he had it when he got a game over...
lol yeah no joke! thanks!