About Store Forum Documentation Contact
Donations:
206$/mo



Post Reply 
Dynamically creating custom objects?
Author Message
SONB Offline
Member

Post: #1
Dynamically creating custom objects?
Hi!

How can I dynamically create custom objects? I made a class "Ship" (extending Item class) for my ships, added OBJ_SHIP to enums, defined a memory block Game::ObjMemx<Ship> Ships, set Game::World.setType(Ships, OBJ_SHIP), made an object in the WorldEditor...
Now how can I create an instance of my object?
Ship &ship = Ships.New(); doesn't work with ObjMemx, so I have to use Game::World.objCreate(), right? Or is there another way to do it?
When I create an object with Game::World.objCreate(), how can I get a reference to the object to be able to control the ship?
04-11-2009 10:39 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
Re: Dynamically creating custom objects?
Hi

Yes objCreate method is the way to go. You can check the tutorial "game basics/dynamically created objects"

You can also user objCreateNear (this will already return a reference to the created object, however this method succeeds only if the destination position is in the world active range, in other case it will return NULL)
04-12-2009 01:57 PM
Find all posts by this user Quote this message in a reply
Post Reply