Author Topic: iOS Canabalt Problems/Solutions  (Read 18587 times)

initials

  • Contributor
  • ****
  • Posts: 378
  • Karma: +0/-0
  • Initials
    • View Profile
    • Initials Blog. Code and other things.
iOS Canabalt Problems/Solutions
« on: Thu, Dec 30, 2010 »
Attempting to run the open source version of Canabalt has a few quirks, and I'm sure I've only scratched the surface.

1. Installing on a device.
If you get the following error:
Code: [Select]
Code Sign error: The identity 'iPhone Developer: Dxxxxx Jxxxxxx (XXXXXXXXXX)' doesn't match any valid certificate/private key pair in the default keychain
Firstly, you should be signed up to the Apple Developer Program. It costs $100 a year approx. Without this you won't be running anything on a device.

So if you are signed up you need to change a setting here:

Project > Edit Project Settings

In the build tab change Code Signing Entity to iPhone Developer. It should say next to it "Currently matches 'your profile' "

Go to Project > Edit Active Target Canabalt.

Do the same thing as above.

Now go down to the Packaging tab change Product Name to something unique.

This prevents installation over the top of the real game!


It should run now.



Lots more information about code signing here:

http://www.codza.com/how-to-fix-iphone-code-signing-errors

« Last Edit: Thu, Dec 30, 2010 by initials »
Initials: Super Lemonade Factory, Super Lemonade Factory Part Two, Above The Clouds, Revvolvver, Four Chambers of the Human Heart

initials

  • Contributor
  • ****
  • Posts: 378
  • Karma: +0/-0
  • Initials
    • View Profile
    • Initials Blog. Code and other things.
Re: iOS Canabalt Problems/Solutions
« Reply #1 on: Fri, Dec 31, 2010 »
The best thing that someone could do with this open source engine is make a template for xCode.

Both the major competitors have a template, Cocos2d and Sparrow.

I'm looking into it, but the jump to Objective C is proving to be quite tricky.
Initials: Super Lemonade Factory, Super Lemonade Factory Part Two, Above The Clouds, Revvolvver, Four Chambers of the Human Heart

jonkk

  • Member
  • **
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: iOS Canabalt Problems/Solutions
« Reply #2 on: Wed, Jan 12, 2011 »
I hope this can help someone, but I just stripped down the Canabalt source to get something simple to start from without losing all the iPhone specific start-up stuff.  So, here's a HelloWorld template for your xCode, easy to install.

Just drop the whole folder into Developers/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/Application

If you notice anything Canabalt-specific I forgot to remove, let me know!

Get it here: https://github.com/bigjko/Flx-iOS-template

initials

  • Contributor
  • ****
  • Posts: 378
  • Karma: +0/-0
  • Initials
    • View Profile
    • Initials Blog. Code and other things.
Re: iOS Canabalt Problems/Solutions
« Reply #3 on: Wed, Jan 12, 2011 »
Thanks, just what I was waiting for!
Initials: Super Lemonade Factory, Super Lemonade Factory Part Two, Above The Clouds, Revvolvver, Four Chambers of the Human Heart

phmongeau

  • Member
  • **
  • Posts: 78
  • Karma: +0/-0
    • View Profile
Re: iOS Canabalt Problems/Solutions
« Reply #4 on: Wed, Jan 12, 2011 »
Wow thank you, I was trying to do this yesterday and I was failing! :D

rajieruone

  • New Member
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: iOS Canabalt Problems/Solutions
« Reply #5 on: Wed, Jan 12, 2011 »
I found other problem with iOS version of flixel...

It have some issues with retina and iPad displays in portrait orientation... sprites are upside down and moved a little. On 480x320 display all works perfectly. I make some investigation and I think that problem is in FlxGame.m and OpenGL setup (buffers). I'm trying to fix it but I don't know OpenGL at all so if anybody can look on it and help I will be grateful.

I also find out that colour filters doesn't work in sprites and now I'm trying figure out what's happening but again its OpenGL ;/

rolandinho

  • Member
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
    • My Portfolio
Re: iOS Canabalt Problems/Solutions
« Reply #6 on: Thu, Jan 13, 2011 »
Thanks for the iOS template. Wanted to so that myself, thanks for that.

rolandinho

  • Member
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
    • My Portfolio
Re: iOS Canabalt Problems/Solutions
« Reply #7 on: Thu, Jan 13, 2011 »
Just tried the template and i get a bunch of errors just with the Hello World text inside.

Things like:
No super class declared or helloText undeclared ...

jonkk

  • Member
  • **
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: iOS Canabalt Problems/Solutions
« Reply #8 on: Thu, Jan 13, 2011 »
That's weird.  Me and two others were able to build it with no problems.  Were you able to build the Canabalt source without problems?

jonkk

  • Member
  • **
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: iOS Canabalt Problems/Solutions
« Reply #9 on: Thu, Jan 13, 2011 »
Also, and I'm no expert at troubleshooting this so hopefully someone else can help as well, but make sure you're running the latest Xcode and iOS SDK.

But yeah, definitely make sure Canabalt builds and runs OK, so we know that it's my template that's wonky.

rolandinho

  • Member
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
    • My Portfolio
Re: iOS Canabalt Problems/Solutions
« Reply #10 on: Thu, Jan 13, 2011 »
That's weird.  Me and two others were able to build it with no problems.  Were you able to build the Canabalt source without problems?

yeah canabalt worked great, even on my iTouch. I also made my own Hello World project from Canabalt and it works - but it's not a template.

Edit: It seems that after restarting everything is working now. it's kind of strange. I didn't change anything. Thanks for the help anyway
« Last Edit: Thu, Jan 13, 2011 by rolandinho »

jonkk

  • Member
  • **
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: iOS Canabalt Problems/Solutions
« Reply #11 on: Thu, Jan 13, 2011 »
Weird.. But great that's it working now!  ;)

festival

  • Member
  • **
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: iOS Canabalt Problems/Solutions
« Reply #12 on: Sat, Jan 22, 2011 »
I hope this can help someone, but I just stripped down the Canabalt source to get something simple to start from without losing all the iPhone specific start-up stuff.  So, here's a HelloWorld template for your xCode, easy to install.

Just drop the whole folder into Developers/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/Application

If you notice anything Canabalt-specific I forgot to remove, let me know!

Get it here: https://github.com/bigjko/Flx-iOS-template

Great!!!!

Better put the template in

/Library/Application Support/Developer/Shared/Xcode

before create a directory "Flixel" and put the template folder in name it "FlixelLandscape" as a portrait version has to be done.


phmongeau

  • Member
  • **
  • Posts: 78
  • Karma: +0/-0
    • View Profile
Re: iOS Canabalt Problems/Solutions
« Reply #13 on: Sat, Jan 22, 2011 »
before create a directory "Flixel" and put the template folder in name it "FlixelLandscape" as a portrait version has to be done.

I don't think we need another template for portrait, you only need to change a little bit of code to change the orientation. In the main file:
change this line (around line 25)
Code: [Select]
if ((self = [super initWithOrientation:FlxGameOrientationLandscape
to
Code: [Select]
if ((self = [super initWithOrientation:FlxGameOrientationPortrait

and that's it. :)

rajieruone

  • New Member
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: iOS Canabalt Problems/Solutions
« Reply #14 on: Tue, Jan 25, 2011 »
really? so try it with canabalt and you will see that there's a bug on Retina display as I wrote few posts above... maybe only I have this problem?

phmongeau

  • Member
  • **
  • Posts: 78
  • Karma: +0/-0
    • View Profile
Re: iOS Canabalt Problems/Solutions
« Reply #15 on: Tue, Jan 25, 2011 »
Actually, you're right, it bugs with retina and iPad. I hadn't tried it before, I was only testing with regular iPhone emulator.

jonkk

  • Member
  • **
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: iOS Canabalt Problems/Solutions
« Reply #16 on: Fri, Jan 28, 2011 »
Better put the template in

/Library/Application Support/Developer/Shared/Xcode

Hmm.. as far as I'd read, that folder is only for non-specific Xcode templates, not iOS templates.  The folder I recommended putting it in, is the same one cocos2d installs its template in.

And yes, there shouldn't be any need for a seperate portrait template, since it's just a switch in code.  But obviously we need to figure out where it's going wrong with portrait mode on iPad.

IQpierce

  • Gamewright
  • Member
  • **
  • Posts: 39
  • Karma: +2/-0
    • View Profile
    • Deep Plaid Games
Re: iOS Canabalt Problems/Solutions
« Reply #17 on: Mon, Feb 14, 2011 »
Did anyone find a fix to this issue with the Retina displays? I'm working on a Flixel iOS game and just ran into this...
I'm just one guy trying to make some interesting decisions!

IQpierce

  • Gamewright
  • Member
  • **
  • Posts: 39
  • Karma: +2/-0
    • View Profile
    • Deep Plaid Games
Re: iOS Canabalt Problems/Solutions
« Reply #18 on: Mon, Feb 14, 2011 »
Just did a little research, this issue only appears to happen if you call FlxGame::initWithOrientation with the value FlxGameOrientationPortrait. If you call it with FlxGameOrientationLandscape (as the Canabalt example does), everything behaves correctly.

I'm seriously considering hacking my game to have this Landscape orientation but just rotate everything I put onscreen... but I suppose I'll look deeper into what the real fix is.

ADDENDUM: D'oh, I hadn't noticed that the fact that this is specific to Portrait has already been reported. Still looking into this anyway.
« Last Edit: Mon, Feb 14, 2011 by IQpierce »
I'm just one guy trying to make some interesting decisions!

IQpierce

  • Gamewright
  • Member
  • **
  • Posts: 39
  • Karma: +2/-0
    • View Profile
    • Deep Plaid Games
Re: iOS Canabalt Problems/Solutions
« Reply #19 on: Tue, Feb 15, 2011 »
Although I got to refresh my memory on OpenGL by digging into the FlxGame::update() function and tweaking the way it does translation/scaling/rotation of the screen for the various zoom modes...

Ultimately my fix was simple: in my FlxGame's primary init function, where it calls [super initWithOrientation...], I no longer ever pass in TRUE for the "useTextureBufferZoom:" parameter (the code provided with Canabalt was passing in TRUE when using an iPads or Retina display). I do however change the "zoom" parameter to be 2.0 when Retina is enabled - and everything just works, the game is scaled up 2x.

Note that I'm not making an iPad game, just an iPhone game that I need to be sure works on iPhone 4... so I haven't tested how this changes iPad behavior yet. In other words, YMMV.

For anyone still looking into fixing this "properly" in FlxGame.m, here's the progress I made:

Around line 760, there's this block of code:
Code: [Select]
if (!textureBufferZoom)
{
switch (gameOrientation)
{
case FlxGameOrientationPortrait:
glTranslatef(backingWidth/2/_zoom, backingHeight/2/_zoom, 0);
glRotatef(actualAngle, 0, 0, 1);
glTranslatef(-backingWidth/2/_zoom, -backingHeight/2/_zoom, 0);
break;
default:
case FlxGameOrientationLandscape:
glTranslatef(backingWidth/2/_zoom, backingHeight/2/_zoom, 0);
glRotatef(90+actualAngle, 0, 0, 1);
glTranslatef(-backingHeight/2/_zoom, -backingWidth/2/_zoom, 0);
break;
}
}

I appended this else block:
Code: [Select]
else  // !textureBufferZoom
{
if( gameOrientation == FlxGameOrientationPortrait )
{
glTranslatef(240, 160, 0);
glRotatef(180+actualAngle, 0, 0, 1);
glTranslatef(-240, -160, 0);
}

}

Essentially this attempts rotate the screen correctly for an iPhone 4 screen. Again this is untested on iPad, and these hard-coded magic numbers probably need to be factors of width/height like in the code block above... this is just what I experimented with and found to work on iPhone 4 retina displays.

There is a major problem with this that I didn't solve however, which is that the bottom 3rd of the screen wasn't being rendered - it was just showing up as black. Input was accepted in this area however. I started looking at the glViewport calls higher in the function to try to resolve this, but I failed to get anything working, and then I realized I could just use my much simpler solution above.

If nothing else, hopefully this will draw Adam's attention to this issue - I'd need to refresh myself on OpenGL more, and read through the Flx rendering code more carefully, to really understand what needs to be done in that function - hopefully this is something he could fix quickly though.
I'm just one guy trying to make some interesting decisions!