Posted By: lostclimate
Arrays of engine object pointers - 09/12/13 18:35
I had this figured out a long time ago, but for the life of me i cant figure out the syntax to have a struct contain an array of engine object pointers.
I want to write my own custom menu struct, and in it I have declared an unitialized TEXT* but every time I try to assign txt_create to it I run into various different problems in everyway i can think to fix it. One way I get a "cant convert pointer to struct TEXT" which doesnt make sense to me because txt_create isnt supposed to actually return the object, but a pointer to. I cant remember how but I can get it to work in the [0] (1st place in the array), after that the other text objects dont seem to function. here is my current code, i think its the "cant convert" problem prev. described in its current state:
It might be a little jumbled, and commented out in weird places because I was trying like 10 diff ways to make it work, but hopefully its still clear what I'm trying to accomplish.
I want to write my own custom menu struct, and in it I have declared an unitialized TEXT* but every time I try to assign txt_create to it I run into various different problems in everyway i can think to fix it. One way I get a "cant convert pointer to struct TEXT" which doesnt make sense to me because txt_create isnt supposed to actually return the object, but a pointer to. I cant remember how but I can get it to work in the [0] (1st place in the array), after that the other text objects dont seem to function. here is my current code, i think its the "cant convert" problem prev. described in its current state:
Code:
........ printm(str_create("blah")); ........ function printm(STRING* msg) { TEXT* msg_txt[2];//=txt_create(msg,6); printm_menu->menu_text=malloc(sizeof(TEXT*)*2); (printm_menu->menu_text)[0]=txt_create(1,8); //(printm_menu->menu_text)[1]=txt_create(1,9); str_cpy(((printm_menu->menu_text)[0]->pstring)[0],str_create("test")); //str_cpy(((printm_menu->menu_text)[1]->pstring)[0],str_create("OK")); (printm_menu.menu_text)[0].pos_x=printm_menu.bg.pos_x+(30*(desktop_size_x/1024)); //positioning (printm_menu.menu_text)[0].pos_y=printm_menu.bg.pos_y+(15*(desktop_size_y/768)); //(printm_menu.menu_text)[1].pos_x=30;//printm_menu.bg.pos_x+(280*(desktop_size_x/1024)); //(printm_menu.menu_text)[1].pos_y=30; //printm_menu.bg.pos_y+(120*(desktop_size_y/768)); // set((printm_menu->menu_text)[0],SHOW); //set((printm_menu->menu_text)[1],SHOW); //set((printm_menu->menu_text)[1],SHOW); set(printm_menu.bg,SHOW); }
It might be a little jumbled, and commented out in weird places because I was trying like 10 diff ways to make it work, but hopefully its still clear what I'm trying to accomplish.