Page 2 of 2

Posted: Thu Jun 28, 2007 6:40 pm
by LemonMan
Alright, I went looking for wchar_t and came up with stringw.

One problem.

Right now this is what part of my code looks like

Code: Select all

health->setText(varhealth.c_str())
This is awesome, but I want it to print out "Health: (varhealth)" not just the number.

How would I do this?

Posted: Thu Jun 28, 2007 6:42 pm
by Irme
My C++ skill is limited, but i believe you do this:

Code: Select all

health->setText("Health: " + varhealth.c_str())

Posted: Thu Jun 28, 2007 8:01 pm
by LemonMan
O.K.

Sorry Irme but that didn't work...

But I did find how to do it by looking at the fps counter at the end of each tutorial.

Code: Select all

int inthealth;

inthealth=100;

stringw varhealth = L"Health:";
varhealth += inthealth;
health->setText(varhealth.c_str());
Output is "Health:100"

YAY! :D

Thank everyone for your help. :)

I'll probably have more problems later though... :P

Posted: Fri Jun 29, 2007 4:40 am
by LemonMan
I have another question.

How would I make my character jump? :P

Posted: Fri Jun 29, 2007 6:24 am
by Dances
Reversing the gravity on your collision would be one way to go about it.

Posted: Fri Jun 29, 2007 7:02 pm
by LemonMan
That would make it so that when you jump you start slow and end fast?
Usualy when you jump you start fast and end slow. :P

I also don't understand the event handler...

Posted: Sat Jun 30, 2007 3:04 am
by Dances
LemonMan wrote:That would make it so that when you jump you start slow and end fast?
Usualy when you jump you start fast and end slow. :P

I also don't understand the event handler...
I don't think Irr's gravity is fancy enough to start you slow. I think you just move a set number of units based on time.

What do you not understand about it?

Posted: Sat Jun 30, 2007 7:13 pm
by LemonMan
Everything...

I mean, something to do with the fact that is a function that comes before the main one and it is referencing nodes and stuff that have not yet been made. Did that make any sense?

Posted: Sun Jul 01, 2007 1:21 am
by Dances
LemonMan wrote:Everything...

I mean, something to do with the fact that is a function that comes before the main one and it is referencing nodes and stuff that have not yet been made. Did that make any sense?
Main is always ran first. Functions can't call themselves. When you write a function before main the program still starts on main. Irrlicht calls the event receiver itself during the device->run() procedure.

Posted: Sun Jul 01, 2007 2:34 am
by LemonMan
Ohhhhhhhh...
That makes more sense.

Could you write me a quick example or the event receiver?

Posted: Sun Jul 01, 2007 4:23 pm
by Dances
LemonMan wrote:Ohhhhhhhh...
That makes more sense.

Could you write me a quick example or the event receiver?
Well... the movement tutorial has a nice simple example of one and how it works...

The GUI tutorial has another nice example of it...

Posted: Sun Jul 01, 2007 11:17 pm
by LemonMan
O.K.

Thank you. :)

Posted: Tue Jul 03, 2007 10:25 pm
by LemonMan
Hi again,

I have gotten the event handler thing but I don't know how to do mouse button handling.

This is the code i'm using,

Code: Select all

IAnimatedMeshSceneNode* uzi = 0;

class MyEventReceiver : public IEventReceiver
{
      public:
             virtual bool OnEvent(SEvent event)
             {
                     if (uzi != 0 && event.EventType == EET_KEY_INPUT_EVENT&&event.KeyInput.PressedDown)
                     {
                              switch(event.KeyInput.Key)
                              {
                                                        case KEY_SPACE:
                                                             {
                                                                       //shoot
                                                             }
                                                             return true;
                              }
                     } return false;
             }
};
help... :P

Posted: Wed Jul 04, 2007 12:23 am
by SwitchCase

Code: Select all

IAnimatedMeshSceneNode* uzi = 0; 

class MyEventReceiver : public IEventReceiver 
{ 
      public: 
             virtual bool OnEvent(SEvent event) 

             { 
                     if (uzi != 0 && event.EventType == EET_KEY_INPUT_EVENT&&event.KeyInput.PressedDown) 
                     { 
                              switch(event.KeyInput.Key) 
                              { 
                                        case KEY_SPACE: 
                                        { 
                                                  //shoot 
                                        } 
                                        return true; 
                              } 
                     } return false; 

// Add code here!!!!!!!!!

             } 
};
This code goes there...

Code: Select all

		     if (event.EventType == EET_MOUSE_INPUT_EVENT)
		     {
			     // switch
				// case
					//stuff
						// goes here
		     }
good luck.

Posted: Wed Jul 04, 2007 4:16 am
by LemonMan
What?