About Store Forum Documentation Contact



Post Reply 
Text && TextStyle problem
Author Message
candam Offline
Member

Post: #1
Text && TextStyle problem
Hello Community smile

I'm having a problem with this simple code I have no idea why the application crash with it



class ChatUser
{
TextLine username; Text user;
Button button ;
TextStyle *ts;
public:
void create()
{
ts.scale = Vec2(1.0, 1.0);
Gui += username.create(Rect_U(0, 0, 2.0, 0.1));
Gui += user.create(Rect_U(-0.2, 0.5, 2.0, 0.7),"Please Add Your username", ts);
Gui += button.create(Rect_U(0, -.5, 0.5, 0.1), "Start Chat").func(saveUser, T);
}
ChatUser()
{

}
void static saveUser(ChatUser &chatuser)
{
LogN(S+chatuser.username());
}

}

After some debugging minutes I found that the problem is here ts.scale = Vec2(1.0, 1.0);

this vector is not read by the engine I have no idea

some help would be great thank you
01-24-2014 12:44 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Text && TextStyle problem
TextStyle *ts;
You're using an uninitialized pointer
01-24-2014 01:04 AM
Find all posts by this user Quote this message in a reply
candam Offline
Member

Post: #3
RE: Text && TextStyle problem
Thank you smile for help

Another problem smile

TextLine username; Text user;
Button button ;
TextStyle *ts;
TextStyle mystyle;
public:
void create()
{
ts = & mystyle;
ts.color = BLACK;
ts.scale = Vec2(0.221, 0.083);
Gui += username.create(Rect_U(0, 0, 2.0, 0.1));
Gui += user.create(Rect_U(-0.2, 0.5, 2.0, 0.7),"Please Add Your username", ts);
Gui += button.create(Rect_U(0, -.5, 0.5, 0.1), "Start Chat").func(saveUser, T);
}


this gives me this result as it supposed to get me a higher font scale but I guess I have another big fault hope someone corrects me grin


[Image: XcbZjyx.png?1?6031]
(This post was last modified: 01-24-2014 01:34 AM by candam.)
01-24-2014 01:19 AM
Find all posts by this user Quote this message in a reply
candam Offline
Member

Post: #4
RE: Text && TextStyle problem
Edit Fixed smile by using
ts.reset();
without it this error happens grin thanks
(This post was last modified: 01-24-2014 01:54 AM by candam.)
01-24-2014 01:54 AM
Find all posts by this user Quote this message in a reply
cmontiel Offline
Member

Post: #5
RE: Text && TextStyle problem
Hmm you don't need that pointer, just pass the reference:

Code:
TextLine username; Text user;
Button button ;
TextStyle mystyle;
public:
void create()
{
mystyle.reset();
mystyle.color = BLACK;
mystyle.scale = Vec2(0.221, 0.083);
Gui += username.create(Rect_U(0, 0, 2.0, 0.1));
Gui += user.create(Rect_U(-0.2, 0.5, 2.0, 0.7),"Please Add Your username", &mystyle);
Gui += button.create(Rect_U(0, -.5, 0.5, 0.1), "Start Chat").func(saveUser, T);
}
(This post was last modified: 01-24-2014 03:56 AM by cmontiel.)
01-24-2014 03:56 AM
Find all posts by this user Quote this message in a reply
Post Reply