joafalves / Gibbo2D

All In One 2D Game Engine
Other
31 stars 10 forks source link

GameObjects Editor #16

Closed Harunx9 closed 10 years ago

Harunx9 commented 10 years ago

Hey i know i can create game object class in c# but i think this may be gibbo editor function. This may be work like i can create new game object like screen and user can add components to object and use this objects in c# coding.

Apidcloud commented 10 years ago

I'm not sure if I got it right, but how's that different from what already happens?

I mean, currently, you create game objects and scripts using the editor. Besides, you can use Lime Scripting Editor in order to edit those scripts (you don't need an external IDE). Finally, after you compile, you can add the components you created, and attach them to the game objects you want.

Harunx9 commented 10 years ago

Eg. i want procedural generation level and my algorithm returns start point, end point, collectibles, enemies and map. In this case i don know how many of this game objects is on the map. If i can make game object in editor and have possibility to call them in C# i have easier mapping feature.

Apidcloud commented 10 years ago

You can create game objects templates in the editor (make them invisible and disabled so they won't be rendered and therefore have no cpu cost) and then clone them via code (change visibility to true and disabled to false). Is that what you need?

Siemienik commented 10 years ago

In code isn't function copy,duplicate or clone.

Apidcloud commented 10 years ago

Please refer to the following forum thread: http://gibbo2d.com/forum/index.php/topic,87.0.html

Tell me if you still have any issues

joafalves commented 10 years ago

You can create objects dynamically. My advice is to create a "template" object in the editor (with the hierarchy and components that you prefer), then on the scripts do:

GameObject templateX = GameObject.Find("myTemplateObj");

if you want to create multiple instances of that object, just:

GameObject templateClone = templateX.Copy(); // or GameObject templateClone = (GameObject)templateX.Clone();

Note: Don't forget to add the copied object to an existing object of the active game scene (or to the scene itself by using SceneManager.ActiveScene.GameObjects.Add(..)). If you don't do this, the object won't be updated / drawn by the engine because its not attached to the active game scene.

Best Regards, John.

Harunx9 commented 10 years ago

Thanks for your replies but i have one more question. Is template obj allocated in CLR memory or not because if i want to have 100 templates this may be cause crash game