• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0

XCode 4.2 and referencing external files

2 posts in this topic

Hello GameDev.net! You guys have always had more insight than I could have asked for into technical problems I've encountered in the past, so I figure I'll bounce this one off you too since A) I don't know the right vocab for a good Google search on this one, and B) That is a fact because all the Google searches I have done ended up having nothing to do with this problem. :P Making a cross post from [url="http://forums.macrumors.com/showthread.php?p=16304007#post16304007"]MacRumors[/url] though since I would like to believe that forum knows more, but I have a solid faith in you guys too.

Anyways, I'm finally taking the dive and trying to learn how to port my C++ game to Mac via XCode. With sfml and opengl, that hasn't been too hard - but I use a custom file type that I read in with ifstream (although I've been told I should switch to fopen eventually) and while I have it working when I click Run in XCode, the OS X App itself does not know how to read in these files. More details below, but, any thoughts?


I am importing this project into XCode essentially, so I took a working SFML framework, added my files, swapped out the main and hit run. Amazingly, all the core stuff worked! The maps (external files in question) did not load though, and it ended up being due to the location of the working directory. Going into XCode's scheme and changing it to be the working dir I use for my old project itself, the maps began loading just fine (since all the map addresses are relative, ie "./maps/world1.map") when I clicked the Run button from inside XCode. Great! But I want to release the game eventually too.

Going into the Derived Data path, where ultimately under Derived Data/Project Folder/Build/Products/Debug I found myGame.app, a 75MB Intel App (so it appears to be sucking up all the music and sound effect files, since the example sfml project before would only make an 8MB app). Trying to run this file by double clicking though makes the project open, but no sound, music, maps, or images load (so none of the external files that were referenced in the working directory). Moving the app into the working directory does not fix this problem either.
So far I have been unable to find a way to build the app directly into the working directory, and am only able to influence its placement by changing Derived Data in Preferences for all of XCode. So, any tips on how to get my final product seeing files the same way that the one run out of XCode sees?

Oh, and as a final note: I'm trying to keep the maps folder separate so that I can easily release new packs of maps without asking people to redownload the whole game, or so that people can fiddle with them and make their own maps. Essentially, I'm trying to keep them visible to the user.

EDIT: And I was wrong! The game does not work flawlessly from XCode, only the first level (the one loaded when building the game) loads properly, every level after that fails to load. I'm guessing that's since after that point, the game is running from the dir where it was built to rather than the one it was built from. Edited by BlinksTale

Share this post

Link to post
Share on other sites
You want to release your project, right?

First you have to make sure that when debugging within XCode it is working flawlessly.
You said that only the first level is loading, and that is really strange. In my projects, I leave the assets/ folder inside MyApplication/MyApplication (where MyApplication is the name of your project) and it works fine.
When building the project, the assets must be copied to the bundle. So make sure that in XCode:
1) Click the Project Name in the Navigation Bar
2) Go to Build Phases
3) Go to Copy Bundle Resources and check if all the resources are listed there. Otherwise click the plus button and add the folder there.

I have never tried using an external resource (except when pulling something from the web and when I was using objective-c).
But I think [url="http://www.techotopia.com/index.php/Working_with_Files_in_Objective-C"]here[/url] might be a start for you to look. This is objective-c though.

Now on to the Release build.
1) Check if your build settings are ok (architecture, etc.)
2) In Product -> Build for Archiving
3) If the above build is successful go to Product -> Archive
4) In the window that will pop up:
5) If you are going to release for App Store click the Validate... button
6) Otherwise you can directly click on Distribute and choose Direct Distribute
7) Choose Export As -> Application

That should work...
I have tried this with SDL before but not with SFML Edited by kuramayoko10

Share this post

Link to post
Share on other sites
And there was my problem! I was leaving all the files inside my Resources folder in the .app, but not the folders with my files. Deleted those, copied over the folders themselves this time including their contents (rather than just the contents) and all the levels load now :) Success!

Except, that's only in XCode. Now when I go to try the game as a standalone .app, it only manages to load things it was not initially asked to load. So, level 1, all the sound effects, music, and menu images fail to load, but levels 2 through the last level work fine. It's just for a demo, so no where near ready for the App store yet (though I appreciate that information!) but even so, having everything load is rather important. :P

I have two folders: my XCode project, and my old repo for the game (since I'm porting it to XCode). Currently XCode is using my old repo as the working dir, and when XCode runs the project, everything loads up. The standalone app loads everything but the initial load this way. I have had it suggested to me that I switch the working dir to MyGame.app/Contents/Resources, which would make sense given that everything is in there, but instead it makes XCode not load any of the initial contents *as well as* the standalone app, so it seems to make things worse.

I figure this thread is still close enough to the topic that I should ask this here too. Any thoughts on why this is, or how it relates?

Many thanks for the help so far kuramayoko10!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0