Byjlnr (dev)
Date 2009-02-21 12:39
Edited 2011-11-09 22:42
Revised:
• check out Gosu from git • create new OpenGL ES project • set up signing stuff as usual • get rid of main.m and the .nib file; also of the prefix header & its settings if you want • add CoreGraphics.framework, OpenAL.framework, AudioToolbox.framework and AVFoundation.framework to your project • comment out the main function, instead implement this global function: Gosu::Window& windowInstance() { static MyWindowSubclass w; return w; }
Then follow this explanation, just instead of ˚CorePlot.xcodeproj use GosuTouch.xcodeproj`:
Missing: Accelerometer support is not there yet (just like on OS X, sadly), but you can already handle touchesBegan/Moved/Ended as a replacement for buttonDown.
Things to note: Touches' coordinates are in screen coordinates (e.g. 0…480, 0…320 on iPhone <4), same for drawing coordinates. You can change both using the undocumented Graphics::setResolution and Input::setMouseFactors if you need to.
Byjlnr (dev)
Date 2012-03-05 11:22
Edited 2013-07-08 00:12
Current version numbers: I use Xcode 4.2/4.3, LLVM 3.x compiler, current iOS SDK but Gosu works with OS Deployment Version down to 3.0 (*all* iOS devices ever shipped).
Not through means that don't void the warranty on your iPhone...I could be wrong, but that's the impression I got when I looked into it. There's no official SDK for Windows iirc.
Byjlnr (dev)
Date 2009-03-04 01:00
Edited 2009-03-04 01:05
Officially, the SDK only works on Intel Macs, even cheap used PowerPC Macs can't be used out of the box. Installing OS X in a VM is supposedly possible but probably illegal in most places in the world (not sure :)), and I have no idea if that or jailbreaking will be a pleasant trip. But if you have some Gosu/C++ code that you'd like to see running on an iPhone/iPod, I can try to package it up and send it back.
Hmm, II wonder if I can automate the creation of the fat file with Xcode? Would be very handy.
BTW, I checked and it turns out that Image's constructor does work with PNG files and even uses UIImage, but only the one that takes a filename. If you want to load PNGs from memory, you'll need the workaround I mentioned.
Regarding the automation of the fat library: I'm almost there, I still don't know if applescripting a little it could be fully automated. The problem: I don't know how to tell XCode to change platform. The approach: create 3 new targets: 1 for device, 1 for simulator and 1 for the fat version. You have to choose the static library template when creating the new target. For each of the targets (except the fat) add all the sources and required frameworks. For the fat target, add the simulator and device version to the targets, so they will be compiled before (they are set as a dependency). Add a new build phase -> new run script build phase to the target, and use a script like this (change it to suit your needs):
the env variable $CONFIGURATION is set by XCode and can be any of Debug, Release or Distribution. This would work great if the simulator or device targets kept their platform settings, so the solution here is to compile each target before building the fat library, that way you make sure that the platform is set correctly for each version of the static library. HTH, r./
For now, I've fixed PNG loading, and the resolution is 480x320 by default now (it was weirdly stretched before, unless you called graphics().setResolution(...)).
You have to open the Xcode project in the mac folder, select Gosu Touch and build it. There are no prebuilt binaries :)
By ?
Date 2010-04-20 01:16
Hello, I am trying to use gosu for an iPhone game. I have set everything up according to the instructions, but have hit one final snag. Using rolando's code above (in my main.mm):
#include "main.h"
#import <UIKit/UIKit.h> #import <Gosu/Gosu.hpp>
class GameWindow : public Gosu::Window { public: GameWindow() : Window(480, 320, true) { }
Weird, _main should be included in libgosutouch.a. Did you run into any trouble compiling the Touch version of Gosu? It actually had compilation bugs until later last night. (Or are you even decrescendo from IRC?)
By ?
Date 2010-04-20 13:54
Ah very close, I am decrescendo's friend working on the same game. I updated Gosu last night and re-compiled with no errors, but that _main error still appeared. This morning I completely deleted Gosu and checked out a clean copy (just in case I tampered with a file), built just fine but still _main error. Do you think it could be a problem with my project? Should I try and create a new project?
Ok I'm trying to increase the userbase of Gosu Touch by many percent here... by jumping on the wagon...
I've followed all of the steps above, and gotten so far as getting the simulator up in debug mode. However... I must be missing something vital, because when the simulator starts my app, it just quits it again immediately... Basically, nothing happens... Xcode just tells me "Debugging terminated" without throwing any errors or anything like that... It's almost as if I'm missing a game loop or something, as if the program just finishes running, but Gosu::Window should take care of that for me, right?
I'm using the most recent version of the SDK...
I'm practically a complete noob with both XCode, C++ and Iphone dev... I managed to create a small game demo in Objective-C and cocos2d for iphone earlier (like 2 years ago), but since I'm working on a game in Gosu now (in Ruby, currently), I'd love to be able to get it running...
One thing I was unsure of was what to do with Gosu Touch once I'd built it... Does it matter where it lies? I mean, when I built it, it seems to have ended up in a folder called "build" in the source folder of Gosu. I haven't entered that search path anywhere in my xcode project, so how could it matter that I built it? I've just entered the header search path and lib path... Could this be related to my problems? I mean, doesn't the build need to be included in my project somehow?
Anyways, any help would be greatly appreciated. It would be totally awesome to use Gosu on the IPhone, even if it means I have to learn C++ (which doesn't seem all that daunting actually)...
> One thing I was unsure of was what to do with Gosu Touch once I'd built it
It should be in <gosuroot>/lib, but it doesn't really matter as long as you adjust the following step:
>>• add -lgosutouch to the linker flags for Release, -lgosutouch-sim to the linker flags for Debug, and make sure the 'lib' folder of Gosu is in the library search path
But a missing Gosu library should actually lead to linker errors on build... Can you see the runtime error in the console window (cmd+shift+R)?
Gee... I'd forgotten about that window. I knew there was important runtime information somewhere... :) Turns out, I just had to delete the reference to the MainWindow-xib file from the plist file in order to get it working. I now have a working Gosu Touch project! Wohoo! Totally awesome actually... :)
I noticed however that changing the screen size doesn't seem to have any effect whatsoever. I have an IPhone 4 so I'd like to use a resolution of 960x640 but it doesn't seem to want to do that... Any tips?
Btw, what's the best way of adding resources to the project? I've tried with a png image and got it working just by putting it in the resources folder in XCode... Is that the way to go generally?
Thanks for your help, it's greatly appreciated! And as always... for the lib itself... :)
Hmmm. You can just call "graphics().setResolution(960, 640)", but I think this should be the default maybe. But you can rest assured that if you draw something at 0.5, 0.5, this will actually be @ 1, 1 on the iPhone 4. I think this is what Apple is doing with UIKit too.
ld: warning: in /Users/jonte/dev/games/gosu-source/lib/libgosutouch-sim.a, file was built for unsupported file format which is not the architecture being linked (armv6) Undefined symbols: "_main", referenced from: start in crt1.3.1.o ld: symbol(s) not found collect2: ld returned 1 exit status
ld: warning: in /Users/jonte/dev/games/gosu-source/lib/libgosutouch-sim.a, file was built for unsupported file format which is not the architecture being linked (armv7) Undefined symbols: "_main", referenced from: start in crt1.3.1.o ld: symbol(s) not found collect2: ld returned 1 exit status
Oh, is the default for iOS projects to compile for armv6 and armv7 now? I think I only compile my game (and Gosu) for armv6. You can probably either fix it by compiling Gosu for both platforms, or your game for armv6. (Target options, architectures)