Epsicode

Hello,

I'm happily testing my game on the XBOX360, but I'm encountering a few issues.

First I'm a bit dissapointed to see that Input.Mouse is not defined in Microsoft.Xna.Framework.Input on a "XBOX360" project, thus it doesn't compile. I would have assumed that PC stuff like inputs would just be ignored on the XBOX...
How can tests the target platform at build time

Second, and most important, I was relying on Enum.GetValues() (Windows build) to get the numbers of items in an Enum list.

Like this:
static public Texture2D[] sprites = new Texture2D[Enum.GetValues(typeof(BulletType)).Length];

However, when trying to build a XBOX game I get this error:
Error 1 'System.Enum' does not contain a definition for 'GetValues' D:\LG-XBOX360\LG-XBOX360\Character.cs 230 68 LG-XBOX360

System is not the same on both platform Is there a work around I was rely counting on that...

Thanks



Re: XNA Game Studio Express System.Enum.GetValues() doesn't exist on XBOX360 ?

MarijnStevens

You can compile a Win32 Only project, but perhaps you need to define an type.

source:
#define Xbox360
//uncomment this line if you compile for windows.
//#undef Xbox360

//... some source here. :)

#if Xbox360
//win32 input.

As for you enum problem, I cant help you, nobody can because of the xna implitation, just like you are likely not allowed to uses IO, to save anything, not sure thought.





Re: XNA Game Studio Express System.Enum.GetValues() doesn't exist on XBOX360 ?

ProfEclipse

If you check MSDN, you will see that GetValues is not supported on XNA (see here). The easiest way to do this is add a final enum value to your enums called Numwhatevers. Then you can use that value (cast to an int) to get the length.



Re: XNA Game Studio Express System.Enum.GetValues() doesn't exist on XBOX360 ?

Stephen Styrchak - MSFT

Epsicode wrote:
First I'm a bit dissapointed to see that Input.Mouse is not defined in Microsoft.Xna.Framework.Input on a "XBOX360" project, thus it doesn't compile. I would have assumed that PC stuff like inputs would just be ignored on the XBOX...
How can tests the target platform at build time

In an Xbox 360 Game project, the following symbol is defined by default: XBOX360. That allows you to use it in preprocessor commands like this:

#if !XBOX360

// Safe to use Input.Mouse

#else

// Use controller or keyboard input.

#endif

You can edit the set of defined symbols by editing the project properties, on the Build tab.

Epsicode wrote:
Hello,
Second, and most important, I was relying on Enum.GetValues() (Windows build) to get the numbers of items in an Enum list.

Like this:
static public Texture2D[] sprites = new Texture2D[Enum.GetValues(typeof(BulletType)).Length];

However, when trying to build a XBOX game I get this error:
Error 1 'System.Enum' does not contain a definition for 'GetValues' D:\LG-XBOX360\LG-XBOX360\Character.cs 230 68 LG-XBOX360

System is not the same on both platform Is there a work around I was rely counting on that...

Thanks

Yes, System is different on the two platforms.

Something similar to the following code may be useful to you. It only works if the enum values are numbered from 0 to n-1, for n values, and you have to know which value is the maximum.

for (int enumValue = 0; enumValue <= (int)EnumType.TheLastEnum; ++enumValue)

{

EnumType next = (EnumType)enumValue;

// Do something with "next"

}

--Stephen





Re: XNA Game Studio Express System.Enum.GetValues() doesn't exist on XBOX360 ?

Epsicode

Ok, thanks a lot everyone !