How exactly would I set up a custom background for my project. As in, a .png file as my background? I've done some testing and it hasn't worked so I'm not really sure how to do it.
You can do that by creating an object that you attach to your camera, as far as possible from it but still in its frustum.
Here's a config example:
[MyBackgroundGraphic]
Texture = path/to/texture
Pivot = center
[MyBackground]
Graphic = MyBackgroundGraphic
ParentCamera = MyCamera
UseParentSpace = both; Use the parent space to define both scale and position
Scale = 1; Makes sure the background is scaled to exactly cover the camera size
Position = (0, 0, 1); Put it as far from the camera as possible but still visible
I think it was that I named the things in the [] differently. Like one was MyBackgroundGraphic and one was Galaxy. Then instead of the correct background image it was just a black background. I'm pretty sure that was the problem.
Yes, I did. I was wondering, I've been editing Grey's tutorials lately to see what I can do and I was thinking about getting boxes to spawn randomly. How would I do that?
For config attributes, read the top comments in the CreationTemplate.ini file, it'll tell you how to use ~ or # in order to get random values.
For delaying and create things randomly over time, it's just code logic, not really something related to orx.
You can either set a variable with a random amount of time to wait, decrement it with the frame DT and when it is less than or equal to 0 you spawn a new object and reinit that variable with a random delay.
You can also use orxClock_AddTimer() if you don't want to handle the delay manually.
and I have it declared in my .ini file, however I'm not sure what to do after that. I was thinking about creating an if statement so that whenever SpawnFloat == 1 a box is spawned. But I'm not sure what to call SpawnFloat in the if statement, as SpawnFloat doesn't work.
Your loop isn't related to a clock, it just sets bSpawnBox to true 68 times for the same object. There's also tutorial on spawners if you want to create objects over time. The executable is in trunk/tutorial/bin.
They're all spawning during the same frame, the u32 parameter tells how many objects are created not the delay. If you want to add delay you have to use the clock. Try the clock tutorial or the spawners one for something automatic.
Just some precisions but here it's not doing what you think it is doing.
You declare a variable inside the if statement, this variable will be limited to the scope of the if (not availabe outside).
Then you set its value to one and that's what is going to be tested, which means this test will always be true.
Lastly, you didn't put any curly braces after the if so only 1 line of code is conditional to the result of the if, and that line is the declaration of the bSpawnBox variable, set to true, and not accessible later on.
So basically, the whole code isn't doing anything that will have any impact at all on anything else and will probably be completely removed by the compiler in an optimization pass (ie. non-debug).
But when I run it I trigger a breakpoint and these messages appear.
FirstProject_d.exe has triggered a breakpoint
Unhandled exception at 0x1001a03e (orxd.dll) in FirstProject_d.exe: 0xC0000005: Access violation reading location 0x00000020.
That probably means you've dereferenced a pointer which value was 0x20 (32). That's definitely not a valid memory address, hence the access violation.
As Grumly suggested, spawners are probably a good bet if you need to time creation of objects. The new timeline module can also be used for that, but I wouldn't try it till you get more familiar with C++ code and orx.
Mmh, what are you trying to do exactly? I have to admit I'm not sure...
Here in the facts you're re-declaring a function of orx. A re-declaration of functions is not something allowed in C/C++.
In your redeclaration you don't specify a type for the first argument of the function, that's why the compiler is trying to interpret orxKEYBOARD_KEY_LEFT as a type (like orxU32, orxFLOAT, etc...), which doesn't make much sense and he's letting you know about it.
OH! Thanks again Grumly, I was overthinking it way too much. Thank you!
EDIT: Just noticed something, whenever I click LEFT or RIGHT just for a second, the movement doesn't stop until I click the other direction. Is there something like orxInput_IsNotActive()?
That's a really basic question there. You should read C tutorials to get the basics because it'll only get more complex as you go deeper into your project.
In the code
if( orxInput_IsActive( "SpawnBox" ) )
is the same as
if( orxInput_IsActive( "SpawnBox" ) == orxTRUE )
so if you want to know when it's not active, you either write
if( !orxInput_IsActive( "SpawnBox" ) )
(thought I'm not sure it works)
or
if( orxInput_IsActive( "SpawnBox" ) == orxFALSE )
If you want to know which functions to use you can right click a similar function and click go to declaration. For example if you right click orxObject_GetName and go to its definition, it brings you to orxObject.h where orxObject_SetPosition is also declared.
There's also the documentation on this site. For this function you'd go to modules and orxObject.
Mmh, what are you trying to do exactly? I have to admit I'm not sure...
Here in the facts you're re-declaring a function of orx. A re-declaration of functions is not something allowed in C/C++.
In your redeclaration you don't specify a type for the first argument of the function, that's why the compiler is trying to interpret orxKEYBOARD_KEY_LEFT as a type (like orxU32, orxFLOAT, etc...), which doesn't make much sense and he's letting you know about it.
What is the error message that the compiler gives when you redeclare a function without specifying the type of the first argument?
Comments
Here's a config example:
Either as a child of another object through the ChildList property or simply in code with orxObject_CreateFromConfig("MyBackground");
Nevermind. :-)
(Can be helpful to someone having a similar problem later on.)
For delaying and create things randomly over time, it's just code logic, not really something related to orx.
You can either set a variable with a random amount of time to wait, decrement it with the frame DT and when it is less than or equal to 0 you spawn a new object and reinit that variable with a random delay.
You can also use orxClock_AddTimer() if you don't want to handle the delay manually.
It's also explained here: http://orx-project.org/wiki/en/orx/config/syntax
orxFLOAT fSpawnFloat = orxConfig_GetFloat("SpawnFloat");
and I have it declared in my .ini file, however I'm not sure what to do after that. I was thinking about creating an if statement so that whenever SpawnFloat == 1 a box is spawned. But I'm not sure what to call SpawnFloat in the if statement, as SpawnFloat doesn't work.
CODE:
But when I run it I trigger a breakpoint and these messages appear.
Oh, and here's the code from the .ini file too.
Darn it! I even tried getting rid of SpawnFloat and using a for statement and that didn't work either.
In your .ini :
In your code
Your loop isn't related to a clock, it just sets bSpawnBox to true 68 times for the same object. There's also tutorial on spawners if you want to create objects over time. The executable is in trunk/tutorial/bin.
Sorry, I tend to post before I think, I figured it out, woops. :P
Just some precisions but here it's not doing what you think it is doing.
You declare a variable inside the if statement, this variable will be limited to the scope of the if (not availabe outside).
Then you set its value to one and that's what is going to be tested, which means this test will always be true.
Lastly, you didn't put any curly braces after the if so only 1 line of code is conditional to the result of the if, and that line is the declaration of the bSpawnBox variable, set to true, and not accessible later on.
So basically, the whole code isn't doing anything that will have any impact at all on anything else and will probably be completely removed by the compiler in an optimization pass (ie. non-debug).
[code]
orxDLLAPI orxBOOL orxFASTCALL orxKeyboard_IsKeyPressed(orxKEYBOARD_KEY_LEFT)
[/code]
I tried it and it's underlined in red and says that the constant orxKEYBOARD_KEY_LEFT is not a type name. How do I fix that?
Again, I'm sorry for having SO many questions. =","BBCode
Mmh, what are you trying to do exactly? I have to admit I'm not sure...
Here in the facts you're re-declaring a function of orx. A re-declaration of functions is not something allowed in C/C++.
In your redeclaration you don't specify a type for the first argument of the function, that's why the compiler is trying to interpret orxKEYBOARD_KEY_LEFT as a type (like orxU32, orxFLOAT, etc...), which doesn't make much sense and he's letting you know about it.
Ok, that makes sense, how would I fix it in that case?
in your ini file you have
in the code there's a part that says So you edit the tutorial and you change it to To go left you'd set the speed to { orx2F(-100.0f), orx2F(0.0f), orx2F(0.0f) };
EDIT: Just noticed something, whenever I click LEFT or RIGHT just for a second, the movement doesn't stop until I click the other direction. Is there something like orxInput_IsNotActive()?
In the code so if you want to know when it's not active, you either write
Wait, how would I get the guy to stop moving though? Setting the speed to 0 doesn't work, it just makes things REALLY glitchy.
edit: forgot to mention "else" to know if it's false.
Anyway, in the beginning of Grey's third tutorial, I can't find anything that sets the position of the position of the soldier, how would I do that?
If you want to know which functions to use you can right click a similar function and click go to declaration. For example if you right click orxObject_GetName and go to its definition, it brings you to orxObject.h where orxObject_SetPosition is also declared.
There's also the documentation on this site. For this function you'd go to modules and orxObject.
edit: if you right click the function name it'll bring you to the declaration of the function where you can see what parameters you can put in.
http://orx-project.org/wiki/en/orx/reference/object/snippets
What is the error message that the compiler gives when you redeclare a function without specifying the type of the first argument?