Object creation in code
#1
Posted 30 November 2010 - 01:05 AM
I wanna know how to create an object in code...but i have no idea how.
So could anyone please show me how to create one in code?
All I know is that the easiest way to do this is by using a script.
#2
Posted 30 November 2010 - 01:58 AM
#3
Posted 30 November 2010 - 02:16 AM
If, however, you want to create a whole new object, in code, you would have to do something like this:
new_object = object_add(); object_set_sprite(new_object,sprite_of_new_object); object_set_solid(new_object,solidness_of_new_object); object_set_visible(new_object,visibility_of_new_object); object_set_depth(new_object,depth_of_new_object); object_set_persistent(new_object,persistence_of_new_object); object_set_mask(new_object,mask_of_new_object); object_set_parent(new_object,parent_of_new_object); //Change the above variables that are the second arguments of the functions above (i.e. solidness_of_new_object should be changed to true or false).Then, to add events to your new object, you would use:
object_event_add(ind,evtype,evnumb,codestr) To give the object a behavior we must define events for the object. You can only add code actions to events. You need to specify the object, the event type, the event number (use the constants that have been specified before for the event_perform() function). Finally you provide the code string that must be executed. You can add multiple code actions to each event.
#4
Posted 30 November 2010 - 02:26 AM
#5
Posted 30 November 2010 - 02:58 AM
"Hp = 100;".
#6
Posted 30 November 2010 - 03:26 AM
Ok...but what about making it do multiple actions in one event?The script for the event of the object. Like in the create event for an object, you might set Hp to 100, so the codestring for it would just be
"Hp = 100;".
#7
Posted 30 November 2010 - 12:01 PM
i.e. codestring would be something like:
hp = 10;
show_message("Object Created!");
if (hp = =10)
{
show_message("This will always happen.");
}
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











