This post is about Objective-C iPhone stuff!
Just because this took me some time to figure out (and might be useful in the future or for other people): In the iPhone SDK a UIScrollView class will eat up all touch events (touchesBegan, touchesEnded, touchesMove, etc.) and not pass them along to your view controller where all your view logic might be (like in my case). If you know this, you can just create a new class for each ScrollView and then have some of your logic there, but in my case all I want is to pass these events along to the UIViewController (like all the other controls behave like). For this reason I just created a simple class called PassTouchesScrollView, which looks like this:
// PassTouchesScrollView.m
// Simple helper class for UIScrollViews that need to pass touchesBegan to the
// UIViewController above it (see all the Controller classes here).
#import "PassTouchesScrollView.h"
@implementation PassTouchesScrollView
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
UIView *result = nil;
for (UIView *child in self.subviews)
if ([child pointInside:point withEvent:event])
if ((result = [child hitTest:point withEvent:event]) != nil)
break;
return result;
}
- (void)dealloc
{
[super dealloc];
}
@end
Note: This is only useful if you really do not need any touch events in the UIScrollView because even the scrolling drag touch events will be ignored and send to the UIViewController. If you want to be more selective, e.g. just pass the touchesEnded event on to the parents via:
-(void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event
{
// Pass to parent
[super touchesEnded:touches withEvent:event];
[self.nextResponder touchesEnded:touches withEvent:event];
}
References: Found helpful tips on StackOverflow and other sites (including this apple support forum).
It wasn't me, so I'm allowed to post a video someone recorded at the GamesCom, where our current game project Fireburst was presented. Fireburst is coming for Xbox 360, PS3 and PC at the end of 2009. For some strange reason everything is still very secret about this project, only a few pictures have been posted so far. But at least we got a leaked video now, hehe. Please note that this is a early beta build, lots of things have been fixed already and we still have some time for tweaking stuff. But the game looks already like a lot of fun (I hope), which is kinda important since so many other racing games are also coming this year. This way our game is at least a little different with all the burning and fire. Please note that the guys talking in the video are speaking German, but its hard to hear anything, mostly static.
Enjoy the video!

Buyaa, I'm Microsoft MVP once again in the XNA/DirectX category for one more year (2009/2010). I have been an XNA MVP since 2006 and I'm still very proud of it :) I was pretty busy this year with our current game project "Fireburst" at exDream (a racing game for Xbox 360, PS3 and PC using the Unreal3 engine, more about it soon) and theirfore I did not do many other things (except writing some iPhone games, starting to develop my own dynamic language and some tools). But once that project is done in 1-2 months, I will do lots more XNA fun stuff and hopefully XNA Community Games (now called Indie Games on the Xbox 360, I really hate that term) will be available in Germany so I can finally review and submit some games myself. I'm still pretty fit in XNA 3.1 and DirectX 11 (played around with it a lot in March), but for XNA I'm still waiting for availablilty in Germany and for DirectX 11 I'm really waiting for some cool hardware at the end of this year. At exDream we recently also had some interesting discussions about using .NET for PS3 (recently possible thanks to Novell), Xbox 360 (hello XNA) and PC or even more dynamic script languages for upcoming projects. Maybe also including some other promising platforms such as iPhone (also .NET able thanks to Unity), Android, PSP Go, WII, whatever, but that all should depend more on the game and if we are able to manage so many platforms. Working with XNA was almost no extra work to make a game run on the Xbox 360 plus the PC, the game just has to fit and you obviously should allow control with the Xbox 360 controller. Our multiplatform game Fireburst is also not that bad to develop for because most issues are handled by the great Unreal3 engine (except the fact of course that it is all ugly C++ and UnrealScript code, which just looks like C++ anyway and even has to be compiled), but it is still quite a lot more work than just doing a PC only game, especially because of optimizations and testing required for all platforms. Enough rambling, I'm going to celebrate this day by installing Windows 2008 server (omg) because our pre-release version we had on there just ran out (warg) .. stupid thing has to be completely reinstalled, no upgrade option ..
After updating so much on my blog the last 2 days and posting all the unfinished posts I had prepared a few weeks ago I finally reach the last important one I wanted to make. But due the fact that I will fly to the MVP summit tomorrow I better not stay away too long. Hopefully this post still contains all the vital information. Let's get started.
First of all you need the latest version of the free NSIS (Nullsoft Installer System):
There are TONS of information on that website and if you are new to the NSIS scripts be sure to read at least the quick start guide (called simple tutorials) and use the NSIS Forums search feature for more specific problems and questions.
Good, now just let us go quickly through the .nsi file I currently use for all my XNA Game Setups. Please note that this file has evolved over many years (I guess I started using NSIS in 2002) and parts might not be simple to read or even be how it is done today, but the script was always a very helpful and quick way to create Setups for me. While detecting all the requirements to make XNA work is not a piece of cake many NSIS tutorials helped me to figure all the parts out.
The following .nsi script is from the previous blog post " Loading Collada Models in XNA 2.0 and doing Skinning and Animation" and was used to build the XnaSkinningColladaModelsSetup.exe (2.2 MB) file. If you want to use it for your own XNA Game project just use a text-editor and replace "XnaSkinningColladaModels" with your own game name (it occurs many times in the file). Also create a .bmp file with the name of your game for the setup header (check MUI_HEADERIMAGE_BITMAP) or comment the 2 Header Image lines out with a ; or # if you do not want any header image. All files are grabbed from the /Release directory and will be installed to the target (make sure that you only have files in the /Release directory that you want to have deployed). This should be already enough information to make your setup work, the rest of this article will just go into the details of the script.
The XnaSkinningColladaModelsSetup.nsi file is organized in 6 parts ( Initialization, onInit, File section, Optional sections, Helper functions and Uninstall):
- Initialization: Just sets all the names, the required modules, and how the setup is displayed to the user (all the pages, see MUI_PAGE). Version information and file information are also a vital part here and you should enter some meaningful values here. Also put any language strings for different languages (this installer is just using english text) at text part of the initialization code.
!include "MUI.nsh"
SetCompressor /SOLID lzma
;Name and file
Name "XnaSkinningColladaModels"
OutFile "XnaSkinningColladaModelsSetup.exe"
;Default installation folder
InstallDir "$PROGRAMFILES\XnaSkinningColladaModels"
;Get installation folder from registry if available
InstallDirRegKey HKLM "Software\XnaSkinningColladaModels" ""
!define MUI_COMPONENTSPAGE_NODESC
;Interface Settings
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install-blue.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall-blue.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "XnaSkinningColladaModels.bmp"
!define MUI_HEADERIMAGE_UNBITMAP "XnaSkinningColladaModels.bmp"
!define MUI_ABORTWARNING
;Pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;Languages
!insertmacro MUI_LANGUAGE "English"
;Version Information
VIProductVersion "1.0.0.0"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "XnaSkinningColladaModels"
VIAddVersionKey /LANG=${LANG_ENGLISH} "Comments" "XnaSkinningColladaModels project, see http://BenjaminNitschke.com"
VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "BenjaminNitschke.com"
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "© BenjaminNitschke.com 2007"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "XnaSkinningColladaModels"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "1.0.0.0"
; The text to prompt the user to enter a directory
ComponentText "This will install XnaSkinningColladaModels for XNA 2.0."
UninstallText "This will remove XnaSkinningColladaModels for XNA 2.0 from your computer."
; New .NET Check function, we want at least v2.0
!define DOT_MAJOR "2"
!define DOT_MINOR "0"
; The text to prompt the user to enter a directory
DirText "Please select a directory for the installation:"
AutoCloseWindow true
- .onInit: This method is executed before the installer is run and can perform any checks you like. I just try to find out if any c:\games directory exists in several languages, if it does, then we can use it, else just use the default c:\program files location.
Function .onInit
;First try to find "Games" (eng), "Spiele" (ger), "jeux" (fr),
; "giochi" (ita), "jogos" (port) or "spelen" (nl) directory!
StrCpy $R1 "C:\Games"
IfFileExists $R1 UseIt
StrCpy $R1 "C:\Spiele"
IfFileExists $R1 UseIt
StrCpy $R1 "C:\jeux"
IfFileExists $R1 UseIt
StrCpy $R1 "C:\giochi"
IfFileExists $R1 UseIt
StrCpy $R1 "C:\jogos"
IfFileExists $R1 UseIt
StrCpy $R1 "C:\spelen"
IfFileExists $R1 UseIt
Goto DontUseIt
UseIt:
StrCpy $INSTDIR "$R1\XnaSkinningColladaModels"
DontUseIt:
FunctionEnd
- File section: This is the most important section and always required because it tells the setup where the files come from (in our case from the Release sub directory) and where they should be installed (in #INSTDIR).
; The stuff to install
Section "XnaSkinningColladaModels"
SectionIn RO
; Set output path to the installation directory.
SetOutPath $INSTDIR
; Put file there
File /r "Release\*.*"
; Write the installation path into the registry
WriteRegStr HKLM "SOFTWARE\XnaSkinningColladaModels" "Install_Dir" "$INSTDIR"
WriteRegStr HKLM "SOFTWARE\XnaSkinningColladaModels" "Version" "v1.0"
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\XnaSkinningColladaModels" "DisplayName" "XnaSkinningColladaModels"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\XnaSkinningColladaModels" "UninstallString" "$INSTDIR\uninstall.exe $INSTDIR"
WriteUninstaller "uninstall.exe"
SectionEnd
- Optional sections: These sections are optional and the user can decide not to create desktop shortcuts, not to install XNA 2.0 if it is not found, etc. I usually leave them all on by default because they make sense. Most important here are the DirectX and XNA prequisites sections, which make a lot of use of the helper functions.
; Optional sections
Section "Create Start-Menu shortcuts"
StrCpy $R1 "$SMPROGRAMS\XnaSkinningColladaModels"
CreateDirectory "$R1"
CreateShortCut "$R1\XnaSkinningColladaModels.lnk" "$INSTDIR\XnaSkinningColladaModels.exe" "" "$INSTDIR\XnaSkinningColladaModels.exe" 0 "" "" "XnaSkinningColladaModels"
CreateShortCut "$R1\XnaSkinningColladaModels Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 "" "" "Uninstall XnaSkinningColladaModels."
CreateShortCut "$R1\BenjaminNitschke.com.lnk" "http://BenjaminNitschke.com" "" "" 0 "" "" "BenjaminNitschke.com website from the creator of this game"
SectionEnd
Section "Create Desktop shortcuts"
CreateShortCut "$DESKTOP\XnaSkinningColladaModels.lnk" "$INSTDIR\XnaSkinningColladaModels.exe" "" "$INSTDIR\XnaSkinningColladaModels.exe" 0
SectionEnd
Section "Check for .NET 2.0 Framework (required)"
Call IsDotNETInstalled
Pop $0
StrCmp $0 1 found.NETFramework no.NETFramework
no.NETFramework:
;MessageBox MB_OK ".NET was not found .."
; First of all check for correct IE version!
Call CheckForCorrectIEVersion
; First check if DotNetFx.exe exists
IfFileExists "$EXEDIR\DotNetFx.exe" 0 DotNetFileNotFound
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" "AutoAdminLogon"
ExecWait '"$EXEDIR\DotNetFx.exe" /q'
StrCmp $R0 1 RestoreAutoLogon End
RestoreAutoLogon:
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" "AutoAdminLogon" "1"
goto End
; If DotNetFx.exe was not found, try downloading online
DotNetFileNotFound:
MessageBox MB_YESNOCANCEL|MB_ICONQUESTION ".NET Framework 2.0 was not found. XnaSkinningColladaModels will not run without it! $\r$\nWould you like to automatically download and install it? $\r$\n $\r$\nChoose Yes for an automatic download and installation. $\r$\nChoose No, you want to select the download yourself (e.g. locally if already downloaded). $\r$\nMicrosoft's .NET Framework Download page will open up! $\r$\nChoose cancel to abort any action here, you will have to install the .NET Framework (2.0) $\r$\nyourself. That can be done for example automatically by the Windows Update $\r$\n(just go to http://windowsupdate.microsoft.com )" IDYES DL IDNO IndirectDL
goto End
IndirectDL:
ExecShell open "http://www.microsoft.com/downloads/details.aspx?FamilyID=0856eacb-4362-4b0d-8edd-aab15c5e04f5" "" SW_SHOWNORMAL
goto End
DL:
Call ConnectInternet ;Make an internet connection (if no connection available)
StrCpy $2 "$TEMP\DotNetFX_Setup.exe"
NSISdl::download http://download.microsoft.com/download/5/6/7/567758a3-759e-473e-bf8f-52154438565a/dotnetfx.exe $2
Pop $0
StrCmp $0 success success
SetDetailsView show
DetailPrint "download failed: $0"
MessageBox MB_OK ".NET could not be installed, download was aborted. Please install .NET yourself! $\r$\nRest of the installation went ok, you just need .NET 2.0 to start XnaSkinningColladaModels!"
goto End
success:
; Install, in quiet mode (will do everything automatically)
ExecWait '"$2" /q'
Delete $2
goto End
found.NETFramework:
;MessageBox MB_OK ".NET is installed, very good ^^"
End:
SectionEnd
Section "Check for DirectX 9.0c (November 2007) (required)"
call IsDirectX9Installed
pop $0
StrCmp $R1 1 maybefound.DirectX9 notFound.DirectX9
maybefound.DirectX9:
; Check if managed directx december 2006 is installed!
IfFileExists "$WINDIR\Microsoft.NET\DirectX for Managed Code\1.0.2911.0" found.DirectX9
notFound.DirectX9:
;MessageBox MB_OK "DirectX9 or better was not found!"
; First check if a file "dx90update_redist.exe" exists
IfFileExists "$EXEDIR\directx_nov2007_redist.exe" 0 DX9RedistFileNotFoundTest1
ExecWait '"$EXEDIR\directx_nov2007_redist.exe" /Q /T:"$TEMP" /C'
; Now install DirectX9
ExecWait "$TEMP\dxsetup.exe"
goto End
DX9RedistFileNotFoundTest1:
; Check again in temp folder
IfFileExists "$TEMP\directx_nov2007_redist.exe" 0 DX9RedistFileNotFound
ExecWait '"$TEMP\directx_nov2007_redist.exe" /Q /T:"$TEMP" /C'
; Now install DirectX9
ExecWait "$TEMP\dxsetup.exe"
goto End
; If that failed, ask user!
DX9RedistFileNotFound:
MessageBox MB_YESNOCANCEL|MB_ICONQUESTION "DirectX9.0c November 2007 or better was not found. XnaSkinningColladaModels needs DirectX9.0c and Managed DirectX runtimes to run. $\r$\nWould you like to automatically download and install it? $\r$\n $\r$\nChoose Yes for an automatic download and installation. $\r$\nChoose No, you want to select the download yourself (e.g. in another language than english). $\r$\nMicrosoft's DirectX Download page will open up! $\r$\nChoose cancel to abort any action here, you will have to install DirectX yourself." IDYES DL IDNO IndirectDL
goto End
IndirectDL:
ExecShell open "http://www.microsoft.com/downloads/details.aspx?familyid=1A2393C0-1B2F-428E-BD79-02DF977D17B8" "" SW_SHOWNORMAL
goto End
DL:
Call ConnectInternet ;Make an internet connection (if no connection available)
StrCpy $2 "$TEMP\directx_nov2007_redist.exe"
NSISdl::download http://download.microsoft.com/download/c/6/a/c6af7ea3-f85c-4fef-a475-5810f82def1f/directx_nov2007_redist.exe $2
Pop $0
StrCmp $0 success success
SetDetailsView show
DetailPrint "download failed: $0"
MessageBox MB_OK "DirectX could not be installed, download was aborted. Please install DirectX yourself! $\r$\nRest of the installation went ok, you just need DirectX 9.0c December 2006 to start XnaSkinningColladaModels!"
goto End
success:
; Install quietly into temp folder
ExecWait '"$2" /Q /T:"$TEMP" /C'
; Now install DirectX9
ExecWait "$TEMP\dxsetup.exe"
; Yeah, we made it!
;why delete, maybe user wants to keep it ^^ Delete $2
goto End
found.DirectX9:
;MessageBox MB_OK "Found DirectX9 or better .."
goto End
End:
SectionEnd
Section "Check for XNA 2.0 (December 2007) (required)"
call IsXNAInstalled
pop $0
StrCmp $R1 1 found.XNA notFound.XNA
notFound.XNA:
MessageBox MB_YESNOCANCEL|MB_ICONQUESTION "XNA 2.0 (December 2007) or better was not found. The XnaSkinningColladaModels needs the XNA 2.0 runtimes to run. $\r$\nWould you like to automatically download and install it? $\r$\n $\r$\nChoose Yes for an automatic download and installation. $\r$\nChoose No, you want to select the download yourself (e.g. in another language than english). $\r$\nMicrosoft's XNA Download page will open up! $\r$\nChoose cancel to abort any action here, you will have to install XNA yourself." IDYES DL IDNO IndirectDL
goto End
IndirectDL:
ExecShell open "http://www.microsoft.com/downloads/details.aspx?FamilyID=15fb9169-4a25-4dca-bf40-9c497568f102" "" SW_SHOWNORMAL
goto End
DL:
Call ConnectInternet ;Make an internet connection (if no connection available)
StrCpy $2 "$TEMP\xnafx20_redist.msi"
NSISdl::download "http://download.microsoft.com/download/b/8/a/b8a1f45a-63e6-4d1f-9c03-55a83d30ee3b/xnafx20_redist.msi" $2
Pop $0
StrCmp $0 success success
SetDetailsView show
DetailPrint "download failed: $0"
MessageBox MB_OK "XNA 2.0 could not be installed, download was aborted. Please install XNA 2.0 yourself! $\r$\nRest of the installation went ok, you just need XNA 2.0 (December 2007) to start the XnaSkinningColladaModels!"
goto End
success:
; Install XNA, quietly does not work on vista for some reason ...
ExecWait 'msiexec /i "$2" /q'
; Yeah, we made it!
;why delete, maybe user wants to keep it ^^ Delete $2
goto End
found.XNA:
;MessageBox MB_OK "Found XNA 2.0 or better .."
goto End
End:
SectionEnd
Section "-Ask some questions"
MessageBox MB_YESNO|MB_ICONQUESTION "Start the XnaSkinningColladaModels now?" IDYES StartRC
goto DontStart
StartRC:
Exec "$INSTDIR\XnaSkinningColladaModels.exe"
DontStart:
SectionEnd
- Helper functions: These little helpers are the utitilies to make all the complex XNA installation steps work. They go through all the steps from making sure .NET is installed, installing it automatically for you if you like, even opening up an internet connection if you are on dialup, checking all the prequisites for installing .NET (like having at least IE 5) and then finally install all the XNA 2.0 and DirectX stuff that is required to run your game on top of that. All without ever leaving the installer and tested on many platforms. I usually do not touch this code unless I have to update some links or include a newer version of .NET, DirectX or XNA. I tried to comment my work, but understanding this script part will not be easy. Just do not expect that any changes you make here will be safe. You need to do a lot of testing in order to add additional functionality here.
; IsDotNETInstalled
;
; Usage:
; Call IsDotNETInstalled
; Pop $0
; StrCmp $0 1 found.NETFramework no.NETFramework
;Function IsDotNETInstalled
; Push $0
; Push $1
; Push $2
; Push $3
; Push $4
;
; ReadRegStr $4 HKEY_LOCAL_MACHINE \
; "Software\Microsoft\.NETFramework" "InstallRoot"
; # remove trailing back slash
; Push $4
; Exch $EXEDIR
; Exch $EXEDIR
; Pop $4
; # if the root directory doesn't exist .NET is not installed
; IfFileExists $4 0 noDotNET
;
; StrCpy $0 0
;
; EnumStart:
;
; EnumRegKey $2 HKEY_LOCAL_MACHINE \
; "Software\Microsoft\.NETFramework\Policy" $0
; IntOp $0 $0 + 1
; StrCmp $2 "" noDotNET
;
; StrCpy $1 0
;
; EnumPolicy:
;
; EnumRegValue $3 HKEY_LOCAL_MACHINE \
; "Software\Microsoft\.NETFramework\Policy\$2" $1
; IntOp $1 $1 + 1
; StrCmp $3 "" EnumStart
; IfFileExists "$4\$2.$3" foundDotNET EnumPolicy
;
; noDotNET:
; StrCpy $0 0
; Goto done
;
; foundDotNET:
; StrCpy $0 1
;
; done:
; Pop $4
; Pop $3
; Pop $2
; Pop $1
; Exch $0
;FunctionEnd
; Call IsDotNetInstalled
; This function will abort the installation if the required version
; or higher version of the .NETFramework is not installed. Place it in
; either your .onInit function or your first install section before
; other code.
Function IsDotNETInstalled
Push $0
Push $1
Push $2
Push $3
Push $4
StrCpy $0 "0"
StrCpy $1 "SOFTWARE\Microsoft\.NETFramework" ;registry entry to look in.
StrCpy $2 0
StartEnum:
;Enumerate the versions installed.
EnumRegKey $3 HKLM "$1\policy" $2
;MessageBox MB_OK "EnumRegKey $3"
;If we don't find any versions installed, it's not here.
StrCmp $3 "" noDotNet notEmpty
;We found something.
notEmpty:
;Find out if the RegKey starts with 'v'.
;If it doesn't, goto the next key.
StrCpy $4 $3 1 0
StrCmp $4 "v" +1 goNext
StrCpy $4 $3 1 1
;It starts with 'v'. Now check to see how the installed major version
;relates to our required major version.
;If it's equal check the minor version, if it's greater,
;we found a good RegKey.
IntCmp $4 ${DOT_MAJOR} +1 goNext yesDotNetReg
;Check the minor version. If it's equal or greater to our requested
;version then we're good.
StrCpy $4 $3 1 3
IntCmp $4 ${DOT_MINOR} yesDotNetReg goNext yesDotNetReg
goNext:
;Go to the next RegKey.
IntOp $2 $2 + 1
goto StartEnum
yesDotNetReg:
;MessageBox MB_OK "DotNet Reg stuff was found!"
;Now that we've found a good RegKey, let's make sure it's actually
;installed by getting the install path and checking to see if the
;mscorlib.dll exists.
EnumRegValue $2 HKLM "$1\policy\$3" 0
;$2 should equal whatever comes after the major and minor versions
;(ie, v1.1.4322)
StrCmp $2 "" noDotNet
ReadRegStr $4 HKLM $1 "InstallRoot"
;Hopefully the install root isn't empty.
StrCmp $4 "" noDotNet
;build the actuall directory path to mscorlib.dll.
StrCpy $4 "$4$3.$2\mscorlib.dll"
;MessageBox MB_OK "Does $4 exists?"
IfFileExists $4 yesDotNet noDotNet
noDotNet:
;MessageBox MB_OK "DotNet was not found .."
StrCpy $0 0
Goto done
yesDotNet:
;MessageBox MB_OK "DotNet stuff was found!"
StrCpy $0 1
done:
Pop $4
Pop $3
Pop $2
Pop $1
Exch $0
FunctionEnd
Function ConnectInternet
ClearErrors
Dialer::AttemptConnect
IfErrors noie3
Pop $R0
StrCmp $R0 "online" connected
Strcpy $R0 "Cannot connect to the internet."
MessageBox MB_OK|MB_ICONSTOP $R0
Quit
noie3:
; IE3 not installed
MessageBox MB_OK|MB_ICONINFORMATION "Please connect to the internet now."
connected:
FunctionEnd
;GetIEVersion
; Based on Yazno's function, [url]http://yazno.tripod.com/powerpimpit/[/url]
; Returns on top of stack
; 1-6 (Installed IE Version)
; or
; '' (IE is not installed)
;
; Usage:
; Call GetIEVersion
; Pop $R0
; ; at this point $R0 is "5" or whatnot
Function GetIEVersion
Push $R0
ClearErrors
ReadRegStr $R0 HKLM "Software\Microsoft\Internet Explorer" "Version"
IfErrors lbl_123 lbl_456
lbl_456: ; ie 4+
ReadRegStr $R0 HKLM "Software\Microsoft\Internet Explorer\Version Vector" "IE"
Strcpy $R0 $R0 4
Goto lbl_done
lbl_123: ; older ie version
ClearErrors
ReadRegStr $R0 HKLM "Software\Microsoft\Internet Explorer" "IVer"
IfErrors lbl_error
StrCpy $R0 $R0 3
StrCmp $R0 '100' lbl_ie1
StrCmp $R0 '101' lbl_ie2
StrCmp $R0 '102' lbl_ie2
StrCpy $R0 '3' ; default to ie3 if not 100, 101, or 102.
Goto lbl_done
lbl_ie1:
StrCpy $R0 '1'
Goto lbl_done
lbl_ie2:
StrCpy $R0 '2'
Goto lbl_done
lbl_error:
StrCpy $R0 ''
lbl_done:
Exch $R0
FunctionEnd
; Checks for current IE version and will try to call
; IE6Setup.exe if it exists, otherwise prompt the user
; to install it for himself (at least IE5.01 is required for .NET)
Function CheckForCorrectIEVersion
Call GetIEVersion
Pop $R0
Push $R1
StrCpy $R1 $R0 1
StrCmp $R1 '6' lbl_IEOK
StrCmp $R1 '5' lbl_IE5
StrCmp $R1 '4' lbl_IEKO
StrCmp $R1 '2' lbl_IEKO
StrCmp $R1 '3' lbl_IEKO
StrCmp $R1 '1' lbl_IEKO
lbl_IE5:
StrCmp $R0 '5.00' lbl_IEKO
Goto lbl_IEOK
lbl_IEKO:
;MessageBox MB_OK "IE5.01 or better was not found!"
; First check if ie6setup.exe exists
IfFileExists "$EXEDIR\Setups\ie6sp1\ie6setup.exe" 0 IE6FileNotFound
ExecWait '"$EXEDIR\Setups\ie6sp1\ie6setup.exe"'
goto lbl_IEOK
; If DotNetFx.exe was not found, try downloading online
IE6FileNotFound:
MessageBox MB_YESNOCANCEL|MB_ICONQUESTION "IE5.01 or better was not found. .NET can't be installed without it! $\r$\nWould you like to automatically download and install it? $\r$\n $\r$\nChoose Yes for an automatic download and installation. $\r$\nChoose No, you want to select the download yourself (e.g. in another language than english). $\r$\nMicrosoft's .NET Framework Download page will open up! $\r$\nChoose cancel to abort any action here, you will have to install IE5.01 or better$\r$\nyourself, that can be done for example automatically by the Windows Update $\r$\n(just go to http://windowsupdate.microsoft.com )" IDYES DL IDNO IndirectDL
goto lbl_IEOK
IndirectDL:
ExecShell open "http://www.microsoft.com/downloads/details.aspx?FamilyID=1e1550cb-5e5d-48f5-b02b-20b602228de6" "" SW_SHOWNORMAL
goto lbl_IEOK
DL:
Call ConnectInternet ;Make an internet connection (if no connection available)
StrCpy $2 "$TEMP\IE6Setup.exe"
NSISdl::download http://download.microsoft.com/download/ie6sp1/finrel/6_sp1/W98NT42KMeXP/EN-US/ie6setup.exe $2
Pop $0
StrCmp $0 success success
SetDetailsView show
DetailPrint "download failed: $0"
MessageBox MB_OK "IE6Setup could not be installed, download was aborted. Please install IE and .NET yourself! $\r$\nRest of the installation went ok, you just need IE for .NET to start XnaSkinningColladaModels!"
goto lbl_IEOK
success:
; Install, in quiet mode (will do everything automatically)
ExecWait '"$2"'
Delete $2
lbl_IEOK:
;MessageBox MB_OK "IE5.01 or better was found .."
FunctionEnd
; Check if DirectX9 or better is installed,
; will return $0 1 then, else $0 is 0.
Function IsDirectX9Installed
Push $0
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\DirectX" "Version"
StrCpy $1 $0 4 3
IntCmp $1 9 found.DirectX9 notFound.DirectX9 found.DirectX9
notFound.DirectX9:
;MessageBox MB_OK "can't find direct9"
StrCpy $0 0
Goto done
found.DirectX9:
;MessageBox MB_OK "found direct9 or better"
StrCpy $0 1
done:
;MessageBox MB_OK "direct9 found value: $0"
StrCpy $R1 $0
Exec $0
FunctionEnd
; Check if XNA 2.0 or better is installed,
; will return $0 1 then, else $0 is 0.
Function IsXNAInstalled
Push $0
;Enumerate the versions installed.
EnumRegKey $0 HKCU "SOFTWARE\Microsoft\XNA\Game Studio" "v2.0"
;if the root directory doesn't exist XNA is not installed
StrCmp $0 "" notFound.XNA found.XNA
notFound.XNA:
;MessageBox MB_OK "can't find XNA"
StrCpy $0 0
Goto done
found.XNA:
;MessageBox MB_OK "found XNA or better"
StrCpy $0 1
done:
;MessageBox MB_OK "XNA found value: $0"
StrCpy $R1 $0
Exec $0
FunctionEnd
- And finally the uninstall section: This section will deinstall your game and get rid of all files in the directory that belong to the game, if there is more, it will not kill any other sub directories or even delete the game directory if there is other data present. If you want to be totally sure that only your game files are deleted, only include files that have been installed in this section via the Delete command. I used 2 RMDir /r commands to delete the Content and ColladaModels directories, which makes things much easier. But if for example the user made screenshots, they will be saved in a /Screenshots directory, which is not deleted here and will stay alive even after the uninstall is complete. There is also another check to make sure the game is still installed at this location by making sure the .exe file still exists. If the .exe file is missing, the uninstaller assumes the game is already uninstalled and it will only remove registry keys, but not any files.
; special uninstall section.
Section "Uninstall"
; REMOVE UNINSTALLER
Delete $INSTDIR\uninstall.exe
; remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\XnaSkinningColladaModels"
DeleteRegKey HKLM "SOFTWARE\XnaSkinningColladaModels"
; remove shortcuts, if any.
Delete "$SMPROGRAMS\XnaSkinningColladaModels\*.*"
Delete "$DESKTOP\XnaSkinningColladaModels.lnk"
; remove directories used.
RMDir "$SMPROGRAMS\XnaSkinningColladaModels"
; First check if rocket commander is located here, if not, dont kill stuff!
IfFileExists "$INSTDIR\XnaSkinningColladaModels.exe" 0 RCNotFound
; remove files
Delete "$INSTDIR\XnaSkinningColladaModels.*"
RMDir /r "$INSTDIR\Content"
RMDir /r "$INSTDIR\ColladaModels"
; Try to kill main folder, but this will fail if there are still some files in it
RMDir "$INSTDIR"
goto End
RCNotFound:
MessageBox MB_OK "XnaSkinningColladaModels.exe was not found in $INSTDIR, won't delete any files, $\r$\nplease remove directory and files yourself (all registry keys were killed)."
End:
SectionEnd
Okay, we have now covered all code of the XnaSkinningColladaModelsSetup.nsi file, download it and check it out for yourself if you want to learn more about it or even use it in your projects. Good luck!
This article is similar to the last one ( How to export .X files from 3DS Max for use in XNA), but this time we are going to export a 3D Model from 3DS Max as a Collada (.dae) file. Most tips are similar, just the output file (Cactus.dae) is different and the engine we will be using is DungeonQuestGDC or the "Skeletal Bone Animation and Skinning with Collada Models in XNA" engine (I will write another article about that in a bit), which support Collada model files.
As I just said, parts of this article will be similar to the last one: First of all you (or your graphic artist) need a version of 3DS Max, I recommend the most recent available version (e.g. Max 2008 has much better support for .DDS files and makes the exporting process way easier). If you do not have 3DS Max, you can test it for 30 days, that should be enough for testing and exporting some existing 3D Models ^^
You will need the ColladaMax Exporter for your Max version, you can find all versions and downloads at the http://www.feelingsoftware.com/ website, more specific information can be found at: http://www.feelingsoftware.com/content/view/65/79/lang,en/. You can register on the site and then download the ColladaMax plugin for 3DS Max for free there.
Similar as discussed in the last article you have to make sure that each mesh that you export has a shader material assigned to it and in order to work correctly with your XNA Graphic engine it must be a shader that is supported by the engine like ParallaxMapping.fx, NormalMapping.fx or some other test shader.
Lets go through all the steps. Please note that experienced 3DS Max users will probably only need the ColladaMax Exporter and figure the rest out themselves. This tutorial is for beginners and people having trouble getting 3D Models exported for the XNA Graphic Engine in DungeonQuestGDC or SkinningColladaModelsInXna (or similar engines). See http://XnaProjects.net for more details and downloads of these projects!
Step 1: Load the Cactus.max (312 KB) model as an example. If you put the used texture Cactus.dds (170.8 KB) in the same directory you should see the following result:
Step 2: In case you can't see the model, also make sure the used Shader ( NormalMapping.fx (10.99 KB, for 3ds Max) for this model, make sure you have a NormalMapping.fx in your XNA Graphic engine) and all other required files exist in the same directory; like the normal map texture CactusNormal.dds (341.47 KB).
If you want to change an existing 3D model and let it use a shader, open up the Material Editor in 3DS Max (e.g. by using the M hotkey) and create a new DirectX shader material. To do that click on a free material spot, click Standard (1.) and then select DirectX Shader (2.), now select the shader you want to use and fill in all the required shader parameters (colors, textures, etc.).
Step 3: Now export the 3D Model as an Collada (.dae) file via the ColladaMax Exporter mentioned above. Make sure settings are similar as follows, basically just activate everything. In case you have animation data in your 3D Model you can also activate the Export Animation checkbox. Multiple animations or the so called Animation Clips do not work very well, so I usually export all the frames and then add some extra animation tracks into an extra .xml file. Anyway, our model does not have any animation and in this case it is much easier both to export and to test.
Step 4: Now you should have the Cactus.DAE (38.95 KB) model file. Unlike previous projects I do not use the XNA Content pipeline for Collada models, I just create a /Models directory and put all the models in there. The textures are stored in /Textures/Models and finally the Shaders go in the /Shaders directory. Thanks to the fact that we do not use the XNA Content pipeline we can keep the game application running while exchanging 3D models and loading them again and again to make improvements, which is cool :)
Step 5: Now with everything in place it is time to test if we can load the model and see it on the screen. I usually use the following unit test in the Model.cs class called TestLoadModel:
Step 6: And finally we should see something like this (this test is from the DungeonQuestGDC engine from http://XnaProjects.net):
I hope this helps.
This little article give tips on how to export an .X file from 3DS Max 8/9/2008 into the XNA Racing Game engine. I got several emails on how to do that and instead of repeating myself, here is the article :) First of all you (or your graphic artist) need a version of 3DS Max, I recommend the most recent available version (e.g. Max 2008 has much better support for .DDS files and makes the exporting process way easier). If you do not have 3DS Max, you can test it for 30 days, that should be enough for testing and exporting some existing 3D Models ^^ Ok, next you will need the Pandasoft DirectX Exporter for your Max version, you can find all versions and downloads here. Also make sure you meet all the prerequisites: http://www.andytather.co.uk/Panda/directxmax_downloads.aspxBefore you start exporting you have to understand that XNA can only render 3D geometry when a shader is used. You can't just put up a gray box like in 3DS Max that easily (if you would like to do that you will need a simple gray box shader). For this reason you will have to make sure that each mesh that you export has a shader material assigned to it and in order to work correctly with the XNA Racing Game engine it must be a shader that is supported by the engine like ParallaxMapping.fx, NormalMapping.fx or some other test shader. Lets go through all the steps. Please note that experienced 3DS Max users will probably only need the Panda Exporter and figure the rest out themselves. This tutorial is for beginners and people having trouble getting 3D Models exported for the XNA Racing Game (or other games that used my XNA Graphic Engine project).
Step 1: Load the Cactus.max (312 KB) model as an example. If you put the used texture Cactus.dds (170.8 KB) in the same directory you should see the following result:
Step 2: In case you can't see the model, also make sure the used Shader ( NormalMapping.fx (10.99 KB, for 3ds Max) for this model, make sure you have a NormalMapping.fx in your XNA Graphic engine) and all other required files exist in the same directory; like the normal map texture CactusNormal.dds (341.47 KB).
If you want to change an existing 3D model and let it use a shader, open up the Material Editor in 3DS Max (e.g. by using the M hotkey) and create a new DirectX shader material. To do that click on a free material spot, click Standard (1.) and then select DirectX Shader (2.), now select the shader you want to use and fill in all the required shader parameters (colors, textures, etc.).
Step 3: Now export the 3D Model as an .X file via the Panda DirectX Exporter mentioned above. Make sure settings in the Texture & .fx files and the X File Settings are as shown below. Most importantly you need to make sure all fx parameters are exported and the file does not use a left handed axis (default behavior) because our XNA engine defaults to the default right handed axis behavior in XNA. Using a binary file type will improve the file loading time.
Step 4: Now you should have the Cactus.X (26.21 KB) model file. You can drag this file and the textures into the Content directory of your project now (1.), then exclude the Cactus.dds and CactusNormal.dds textures (2.) because they are automatically generated by the dependencies in Cactus.X. Finally click properties of the Cactus.X file (3.) and make sure you use the XnaGraphicEngine Model (Tangent support) content processor (4.).
Step 5: Now with everything in place it is time to test if we can load the model and see it on the screen. I usually use the following unit test in the Model.cs class called TestSingleModel:
Step 6: Which finally leaves us with the result if everything worked out. It rarely does on the first try, go through the steps again and make sure all files are there and you can use the shader and textures in the engine as expected, you might have to rename shaders and directories and resave the .x file until everything is correct. BTW: I used the XnaRacingGame engine from http://XnaProjects.net here. Good luck :)

Even when I did not post much last week I was very busy converting all the old XNA 1.0 games to XNA 2.0. I did not only convert all projects (8 games in total, see below), but I also tested them extensively on Windows XP, Vista (32 and 64 bit) and the Xbox 360. Additionally a lot of usability improvements have been implemented in the games, for example the XNA Shooter is now much easier (was almost impossible to even reach 50% of the level) and a lot more fun due better balancing. The XNA Racing Game has now a better physic engine and will not longer let the car fly out of the track or leave ground in loopings. Due the better input control and fixed physics the cars drive now much faster and it is more challenging to complete the tracks in shorter time frames.
Games in this article:
Please read my previous post about Converting XNA 1.0 games to XNA 2.0 for all technical tips. All the games can also be found on http://XnaProjects.net, but I will also make them easier accessible on this blog soon, which has an update overdue (need to clean up the left and right sides) ^^
Thanks to the great VS2005 support of XNA 2.0 all games have now just one single solution file, which works on Windows and the Xbox 360. The projects can be opened in XNA Game Studio 2.0 and Visual Studio 2005 without having to convert the files over and over again like in the past. The Icons for all games were also improved. Lets take a look at the Icons (.ico files) on Windows:
For the Xbox 360 game icons the .png files (usually named GameThumbnail.png) are used:
Ok, let's take a look at the games and what has changed for them. Most games are pretty much the same as for XNA 1.0, but a lot of smaller bugs were fixed and they have been tested more.
- Chapter1Game: This application is not really a game, but a test project to check out if XNA 2.0 is properly working on both Windows and the Xbox 360. It is from the first chapter of my book "Professional XNA Game Programming". BTW: The second edition of the book is coming out soon, there are 3 more chapters about Multiplayer game programming and a cool new role playing game.
- Xna Pong: Xna Pong is a simple clone of the favorite pong game from 1978. It is just a few hunderd lines of code and should be very easy to understand.
This game is from the book "Professional XNA Game Programming" by Benjamin Nitschke. For more information read chapter 2. (2008-02-10: Now updated to XNA 2.0)
- Xna Breakout: XNA Breakout is a simple Breakout/Arcanoid game based on the XNA Pong game from the previous chapter.
It is fully described and covered in Chapter 3 of my book "Professional XNA Game Programming". The code is quite short and should be easy to understand. (2008-02-10: Now updated to XNA 2.0)
- Xna Tetris: This is a simple, but highly addictive Tetris game. You can control the blocks with your cursor keys, aswd or a game pad and the game works both on Windows and the Xbox 360. Reaching levels above 5 is really hard. My highest level was 9, try to reach more :) (2008-02-10: Now updated to XNA 2.0)
This game introduces the helper classes (chapter 4 of my book) and makes more use of unit testing and game components in XNA.
- Rocket Commander Xna: XNA port of the famous Rocket Commander game. The game principle stayed the same, but the controls were a little bit simplified to make it more fun on the Xbox 360.
If you want to learn more about the Rocket Commander game, check out its official website www.RocketCommander.com and check out the Video Tutorials on Coding4Fun by MSDN. (2008-02-10: Now updated to XNA 2.0, also supports very big resolutions now and runs faster on the Xbox 360)
- Xna Shooter: Shoot'n'up game specifically created for my book "Professional XNA Game Programming". It features full HDTV support, runs on Windows and the Xbox 360, 5 weapon types, 5 enemy types, a powerful ship and some power ups. It is quite fun to play and it gets harder and harder the longer you play. Based partly on the Rocket Commander XNA engine, but also features lots of new effects and shaders. (2008-02-10: Now updated to XNA 2.0, also much easier and balanced)
This game and the racing game are the most improved. The game works now much better in high resolutions and on the Xbox 360. But most importantly the game is now much easier, balanced and more fun. Additionally a level percentage is now visible on the bottom and more EMP bombs can be picked up to make it easier at the end of the level.
- Xna Racing Game: XNA Racing Game Starter Kit I wrote for http://creators.xna.com. More information and more downloads can be found on http://XnaRacingGame.com. It runs best on the Xbox 360 in HDTV (1920x1200), but it also runs fine on the PC. (2008-02-10: Now updated to XNA 2.0, driving also improved a lot, better tested on Xbox 360 and fixed some issues).
Following things were improved: Shadow mapping on very big resolutions works now (crashed before), more options for lower quality settings, fixed physics, car now always stays on the road, fixed loopings, cars are much faster now, winning conditions work better now, and fixed several other bugs.
- Dungeon Quest GDC: And finally the Dungeon Quest XNA Game, which was developed in just 4 days on the GDC 2007 at the XNA Contest. Dungeon Quest GDC is a relatively complex 3D role playing game (at least for just 4 days of work). An early version even supported coop multiplayer on the Xbox 360 via splitscreen. The game was developed by Benjamin Nitschke (abi.exDream.com) and Christoph Rienaecker (WAII). (2008-02-10: Now updated to XNA 2.0). This is NOT the full Dungeon Quest game (see www.DungeonQuestGame.com for that), this is just the GDC version.
Please note that the level was reduced to allow loading on the Xbox 360 (which otherwise crashes with an OutOfMemoryException), the game is not fully playable, only the first part is implemented. You can also press F2 to toggle the Options menu and some minor bugs were fixed. But this game is no longer supported, I will not improve it anymore! Please check out the new Dungeon Quest game from www.DungeonQuestGame.com, which is coming in a month or so.
Have fun with all the games :)
 When I wrote this (a little bit each day while working on converting the old XNA projects) I was very aware about the disappointment of my blog readers about the fact that I did not blog much in the last couple of months, especially on XNA. I not only got a lot of emails about that, but also quite a lot of questions, especially since XNA 2.0 was released. I made yet another promise to myself to change that and finally blog more, maybe not only when something very interesting pops up, but instead about the everyday issues I run into. Some Notes about XNA 2.0: More solid, lots of little new features, networking, while it may not be a very complete solution, at least it is now possible on the Xbox 360 and overall I have the feeling even more people are interested in XNA than a year ago. Plus the guys at the XNA Team doing a great job and are constantly improving the XNA Creators Club website for us game programmers and artists :)
 Several people had problems using the old XNA 1.0 code of my games and make them work with XNA 2.0, so here is a little help in case you want to convert XNA 1.0 projects to XNA 2.0. You will also notice this if you go to any XNA community site as most samples will still be in XNA 1.0 and not work out of the box in XNA 2.0, and many of those will probably never be changed since they are not longer actively being developed. For most games almost all of the code can stay unchanged, you just have to poke at a few things that have changed in the framework or were improved. More information about converting projects can be found here (read this first, this article is based on the stuff there). You can also use the Cross-Platform Game Project Converter from XNA 2.0 to add a Xbox 360 project to your existing Windows XNA project without having to create a separate project (it is helpful, but I used pretty much the same trick for all of my XNA 1.0 games anyway). Let's go through the steps: - Either use the XNA project conversion utility (can be found on the XNA Creators Club website) or just create a new XNA 2.0 project in VS 2005.
- If you created a new project, drag all source code files into the project and seperate the content files out and put them all in the existing Content directory (only there the content pipeline is activated). If you just converted a project and the content files did not move, move them yourself to the content directory. Gladly all my projects with more than 5 content files had a special content directory anyway, so no need to change anything content-wise for them. If you don't want some of the files to be compiled to .xnb files, you have to change the build action from "compile" to "content" (and then use the "copy to output directory" switch) or to "none" if you want them to be ignored like for .wav files, which are automatically processed by the .xct (XACT) file for you.
- Find the line content = new ContentManager(Services); and replace it with Content.RootDirectory = "Content";. If you do that, get rid of the content manager in your game class since you can now use the build-in Content property to access the underlying Game content manager. In case you don't want to do that or if you need an extra variable, replace the above line with content = new ContentManager(Services, "Content");. Both ways will make sure all the content is now loaded from the content directory instead from the main directory of the application. In more complex XNA games you can also change the BaseGameDirectory to the content directory, but then you would also have to move all other resource files to this directory (config files, save games, levels, etc.). It is usually a good idea to separate the compiled (.xnb) content from the content the user can change (config, levels, etc.), so I suggest just redirecting the content directory of the content manager.
- Replace the LoadGraphicsContent(bool) method with LoadContent, remove all the if (loadAllContent) commands (was never false anyway, just let the content of the if loop stay) and also remove the call to base.LoadGraphicsContent(bool) (does not do anything like all the Load or Unload methods in the XNA Game class, they are just empty virtual methods). You can also ignore this and the next step since it will only generate depreciated warnings, but I suggest cleaning up your source code whenever an opportunity like this presents itself. I also added some missing region blocks to the code and some comments here and there were they were missing.
- Finally delete the UnloadGraphicsContent method unless it did anything beside base.Unload and base.UnloadGraphicsContent. In my XNA games the UnloadGraphicsContent usually looked like this and can be safely removed now (at least if nothing else is in there):
/// <summary> /// Unload graphic content if the device gets lost. /// </summary> /// <param name="unloadAllContent">Unload everything?</param> protected override void UnloadGraphicsContent(bool unloadAllContent) { if (unloadAllContent == true) content.Unload();
base.UnloadGraphicsContent(unloadAllContent); } // UnloadGraphicsContent(loadAllContent)
- In case you load sound and music via the AudioEngine, you have to change the directory to the content directory too, which will not be done automatically for you since you load the .xct file directly in the AudioEngine constructor. Basically just exchange the following code:
audioEngine = new AudioEngine("YourSound.xgs"); waveBank = new WaveBank(audioEngine, "Wave Bank.xwb"); soundBank = new SoundBank(audioEngine, "Sound Bank.xsb");
with:
audioEngine = new AudioEngine("Content\\YourSound.xgs"); waveBank = new WaveBank(audioEngine, "Content\\Wave Bank.xwb"); soundBank = new SoundBank(audioEngine, "Content\\Sound Bank.xsb");
- In case you have used the StorageDevice and specifically the ShowStorageDeviceGuide helper method, it is gone now in XNA 2.0. I had it in some helper classes, but never actually used it. In case you want to show a save game dialog (or some network game select dialog for example), please follow the XNA 2.0 help instructions to do this asynchronously now.
- In case you use any ResourceUsage enum, replace it with TextureUsage instead or remove it if the issue is not texture related. You can also safely remove any ResourceManagementMode.Automatic parameters, which are not longer supported. Everything is now automatic anyway. Just if you have been using ResourceUsage.RenderTarget you will need to change the Texture2D class to a ResolveTexture2D class in order to archive the same behaviour as before. Some calls to the device (e.g. ResolveBackBuffer) have also changed and require a ResolveTexture2D now. You may also want to check if you have any manual texture management or disposing, which you can remove or simplify.
- For simpler games (2D) games you should be done now. More complex games using render targets and other features that have changed in XNA 2.0 will require some more changes, but after you have done them once (or know where to change what) this is also a quick process.
The following only applies to the RocketCommanderXna, XnaShooter and XnaRacingGame engines, but you might find similarities with other XNA games and the converting process: - First of all make sure the old XNA 1.1 code gets compileable by going though the changes mentioned above (e.g. replacing ResourceUsage with TextureUsage or BufferUsage) and removing everything that does not exist anymore (like ResourceManagementMode.Automatic). If a method is non-existent in XNA 2.0 like ResolveRenderTarget, comment it out and remember where it happened.
- You might go through other issues, but you have to come back to the RenderTarget issue. This took the most time in the converting process for me (probably half of all my issues come by something related to changes with RenderTargets in XNA 2.0). For that reason always make sure that rendering to textures still works while you make changing. I always used the TestCreateRenderToTexture unit test inside the RenderToTexture class to figure things out.
- Additionally to making some changes in the BaseGame class (loading content via LoadContent, using the base.Content instead of creating a new content manager, etc.) I also removed all the RenderTarget helper methods and fields from the BaseGame class (SetRenderTarget, ResetRenderTarget, etc.) and moved them into the RenderToTexture class. While this makes the code more clean and restructured by making a few more fields private, if you do not call the new InitializeDepthBufferFormatAndMultisampling of the RenderToTexture class the calls to SetRenderTarget and ResetRenderTarget will not work correctly and will not restore the default depth buffer (which has to be remembered first). If you get the following exception it means the DepthBuffer Device.DepthStencilBuffer was set to null, but is obviously still used. In order to fix that make sure the remDepthBuffer variable is set to a correct value in the InitializeDepthBufferFormatAndMultisampling method!
An error has occurred during the Clear operation while trying to clear the depth or stencil buffer, no DepthStencilBuffer surface exists. System.InvalidOperationException: An error has occurred during the Clear operation while trying to clear the depth or stencil buffer, no DepthStencilBuffer surface exists. at Microsoft.Xna.Framework.Graphics.GraphicsDevice.Clear(ClearOptions options, Color color, Single depth, Int32 stencil, Rectangle[] regions) at Microsoft.Xna.Framework.Graphics.GraphicsDevice.Clear(Color color)
- 4. Even if you have now done everything, the app may still crash when you are trying to clear a render target (which usually happens at the start of each pre or post screen shader). The reason for the following error is the multi sampling format, which might be set to the background buffer, but not to the render targets:
The active render target and depth stencil surface must have the same pixel size and multisampling type. System.InvalidOperationException: The active render target and depth stencil surface must have the same pixel size and multisampling type. at Microsoft.Xna.Framework.Graphics.GraphicsDevice.VerifyDepthRenderTargetCompat() at Microsoft.Xna.Framework.Graphics.GraphicsDevice.Clear(ClearOptions options, Color color, Single depth, Int32 stencil, Rectangle[] regions) In order to get rid of this error without changing the RenderToTexture class a lot, you can just comment out the line where multi sampling is activated in BaseGame:
//this.graphics.PreferMultiSampling = true;
There are probably even more things that I forgot while converting the projects (converted 8 games and about 15 projects in total now), but the above list should be helpful. Especially for me because I always forget some of those little things and having this checklist is very helpful. Tomorrow I will probably test all the XNA 2.0 games on my Xbox 360 and make some final adjustments and then post them all on http://XnaProjects.net (and here).
Microsoft XNA: Ready for Prime Time?
is the name of the Article of the CoDe Magazine. It is very well written and a really long (9 pages) read with tons of information in it. Together with 6 other guys I was interviewed about my experiences with XNA and the development process of the XNA Racing Game and Dungeon Quest, which are 2 of the best looking XNA games so far :) Check it out, good work Nick Landry.
 I heard about all the Silverlight fuss from the MIX2007 conference last week, but I did not have time to check it out with all the stress and projects I'm currently involved in. I already use VS Orcas for a while (see post from last month) and I played around with WPF in the past (formerly Avalon, now Silverlight, which is still in beta, but will be released this summer finally), but I did not find anything compelling for a game programmer since we use DirectX or XNA anyway. But with the ability to build websites with Silverlight and still allowing the .NET framework to exist in that environment while simplifying the development process and getting away from building static html like pages with some dynamic features (ajax or not, it is still somewhat static and hard to do), Silverlight gets much sexier than just WPF on a windows app by itself. Why is Silverlight cool? It is .NET, it runs on Firefox, IE, Safari, Mac, etc. it is just 2 MB download, it is amazingly fast, it has many cool new features, it allows many windows-only apps to be developed for the browser in a more natural way, it will be pushed like crazy and a lot of people will have it till the end of this year, there are already some cool tools out there including the Expression toolkit and Visual Studio Orcas, and probably a lot of other reasons you can checkout yourself! Maybe it is even possible to interop with some DirectX or XNA stuff somehow. I have no idea if this is possible at all or if there are security issues or this kind of functionality is not possible at all, but instead of waiting for another week until I find a few minutes to test this out, why not announce it here first that this would be cool and maybe someone else can test it for me :) Even for just doing websites, Silverlight will definitely become a BIG competitor to Flash based websites, developing in .NET will be a lot easier than working with Flash/Actionscript/whatever and I would bet that there are more VB/C# developers that can now do some great websites without having to learn much while creating Flash sites or even doing ASP.NET (with or without Ajax) development is much harder and less compelling for certain kinds of applications. Great examples are the FOX Movies site and some widgets on MSDN or some early test controls from Telerik. BTW: Archor wrote me an email about his Cyber Car XNA game he wanted to submit to the XnaProjects.Net site I made last week. This is actually a Racing Game Mod, I first guessed he used the simple racing game version, but this one is based on the full racing game from the XNA creators website. Pretty cool style in my opinion. Thanks Archor! http://xbox360.archor.com/
|
|
|