Adding Code to a class
Monkey Forums/Monkey Programming/Adding Code to a class
| ||
Hi is there a way to add code to a class while the program is running? Say i have an object and i want to add or reduce More functions (or methods) is it possible ? cheers |
| ||
No you can't, but why would you want to? |
| ||
i want to make a map editor and when i want to add a function to an object how could i do that? let say the object was going back and forward and now i want it also to jump.. any idea? |
| ||
The way you would do it is to not design it that way in the first place. This kind of behaviour should be in your compiled code, not in your editor. If you want to do everything in your map editor, you need to use a scripting language. Maybe wait until we have interpreted Monkey... Alternatively, you could implement some kind of aggregate system... do a search for component-based game design. It requires you to rethink your design paradigm a bit, but there's a lot of buzz about it recently. A good example is Replica Island. |
| ||
tnx samah ive started to make an engine long time ago where you create an object and then you can add to it functions and trigger and sons.. each sons can have its own functions as well then after building a prefab you can clone it and reuse it. all while the game is running... all went well but still it wasnt on the scripting level so it was limited to premade functions and triggers. ive abandoned it. |