Crash on txt_create

Posted By: MMike

Crash on txt_create - 07/14/10 01:27

Hello this is my code..
Whats wrong? because i assign apointer to the text, and then when i try to move it.. it crashes..

Code:
#include <acknex.h>
#include <default.c>
#include <litec.h>


TEXT* txt1;
STRING* txt1_content="alternative";

function load_text(TEXT* a, STRING* b){
a=txt_create(1,2);
(a.pstring)[0]=b;
set(a,SHOW);
}



function main(){
vec_set(screen_color,vector(53,53,53)); 
video_window(NULL,NULL,16,"TEST");
video_set(800,600,0,0);
level_load(NULL);
wait(1);
reset(camera,SHOW);


load_text(txt1,"Hellllo");
wait(-5);
//move the texto to right 
txt1.pos_x=200;
}


Posted By: tD_Datura_v

Re: Crash on txt_create - 07/14/10 13:34

Probably the TEXT pointer is not assigned correctly.
You could try to do something similar to the following:
Code:
#include <acknex.h>
#include <default.c>
#include <litec.h>


TEXT* txt1;
STRING* txt1_content="alternative";

TEXT* load_text(STRING* b){
	TEXT* a = txt_create(1,2);
	if (a != NULL) {
		if (b != NULL) {
			str_cpy((a.pstring)[0], b);
		} else {
			str_cpy((a.pstring)[0], "");
		}
		set(a,SHOW);
	}
	return(a);
}



function main(){
	vec_set(screen_color,vector(53,53,53)); 
	video_window(NULL,NULL,16,"TEST");
	video_set(800,600,0,0);
	level_load(NULL);
	wait(1);
	reset(camera,SHOW);


	txt1 = load_text("Hellllo");
	wait(-5);
	//move the texto to right 
	txt1.pos_x=200;
}


Posted By: MMike

Re: Crash on txt_create - 07/24/10 00:32

well for this then i will just use on the main()

the txt_create method and that works.
© 2024 lite-C Forums