Delphi Sprite Engine – Part 5.5 – Deploying to iOS or Android

pacman

[If you’re new to this series, you may wish to skip ahead to part-7, where I’ve done a partial ‘start-over’]

It’s time for a little house keeping, and to see this sprite engine deployed to iOS and Android.

At the end of part 5, I found myself dissatisfied with the sprite engine code so far. It has several warnings, an ugly fix to TSprite.Render() to resolve missing textures when deployed to ARC, and I’ve not yet demonstrated deployment to iOS and/or Android.

So I’ve decided to slot this part 5.5 in here to address these issues.

Code tidy up.

I’ve gone through the code and resolved any outstanding warnings. I’ve also removed the ‘fMaterial’ private member from the TSprite class, and instead of keeping that local reference, I’ve added a TMaterialSource to the TSpriteSheet class. This TMaterialSource is private, but may be accessed through the public ‘SourceImage’ and ‘Material’ properties.

Get the latest sources here: SpriteEngine_r4

Deploying to Android.

When you extract the source code file above, set the target for the ‘SpriteEngineTest’ to ‘Android’ and hit run, you’ll find that the project already contains the deployment options to send the ‘pigeon.dat’ file over to the android device.

In the IDE select “Project/Deployment” from the menu and ensuring that “debug configuration – android platform” is selected in the drop-down at the top, notice that I’ve set the remote path for ‘pigeon.dat’ to “assets\internal”.

In code, this location is addressed in the OnCreate event handler for the form:

FS := TFileStream.Create(TPath.GetDocumentsPath + PathDelim + 'pigeon.dat',fmOpenRead);

As a result, the application is able to locate and load ‘pigeon.dat’ and…

20150309_164012

Deploying to iOS

Just as with the Android platform above, the source code download above is pre-configured to deploy the ‘pigeon.dat’ file to the iOS device. Take a look at the deployment options as you did for the android platform and you’ll notice that the remote path is set to ‘StartUp\Documents’ the result…

20150309_164725

Deploying to Windows

As I’m sure you’re aware by now, deploying to windows is as simple as ensuring that the ‘pigeon.dat’ file is sitting right along-side the exe when you launch the application.

Deploying to Mac

I’ve not tried deploying to Mac yet, though it should be a matter of altering the conditional defines in the forms creation so that Mac targets also expect the .dat file next to the binary executable, and then deploying the file accordingly. I’ll update on this when I actually try it.

Conclusion

With cleaner code, and deployment demonstrated, I now feel a lot better about proceeding on to our next goal! See you next time.

Thanks for reading!

Print Friendly, PDF & Email
Facebooktwittergoogle_plusredditpinterestlinkedintumblrmail

Leave a Reply