Flixel Forums

development => iOS => Topic started by: initials on Thu, Dec 30, 2010

Title: iOS Canabalt Problems/Solutions
Post by: initials 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

Title: Re: iOS Canabalt Problems/Solutions
Post by: initials 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.
Title: Re: iOS Canabalt Problems/Solutions
Post by: jonkk 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
Title: Re: iOS Canabalt Problems/Solutions
Post by: initials on Wed, Jan 12, 2011
Thanks, just what I was waiting for!
Title: Re: iOS Canabalt Problems/Solutions
Post by: phmongeau on Wed, Jan 12, 2011
Wow thank you, I was trying to do this yesterday and I was failing! :D
Title: Re: iOS Canabalt Problems/Solutions
Post by: rajieruone 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 ;/
Title: Re: iOS Canabalt Problems/Solutions
Post by: rolandinho on Thu, Jan 13, 2011
Thanks for the iOS template. Wanted to so that myself, thanks for that.
Title: Re: iOS Canabalt Problems/Solutions
Post by: rolandinho 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 ...
Title: Re: iOS Canabalt Problems/Solutions
Post by: jonkk 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?
Title: Re: iOS Canabalt Problems/Solutions
Post by: jonkk 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.
Title: Re: iOS Canabalt Problems/Solutions
Post by: rolandinho 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
Title: Re: iOS Canabalt Problems/Solutions
Post by: jonkk on Thu, Jan 13, 2011
Weird.. But great that's it working now!  ;)
Title: Re: iOS Canabalt Problems/Solutions
Post by: festival 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.

Title: Re: iOS Canabalt Problems/Solutions
Post by: phmongeau 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. :)
Title: Re: iOS Canabalt Problems/Solutions
Post by: rajieruone 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?
Title: Re: iOS Canabalt Problems/Solutions
Post by: phmongeau 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.
Title: Re: iOS Canabalt Problems/Solutions
Post by: jonkk 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.
Title: Re: iOS Canabalt Problems/Solutions
Post by: IQpierce 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...
Title: Re: iOS Canabalt Problems/Solutions
Post by: IQpierce 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.
Title: Re: iOS Canabalt Problems/Solutions
Post by: IQpierce 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.
Title: Re: iOS Canabalt Problems/Solutions
Post by: axcho on Fri, Mar 11, 2011
Thanks for sharing your fix, IQpierce.

Lately I've been trying Cocos2D (http://www.cocos2d-iphone.org/) for iPhone game development, but after being spoiled on Flixel, it is so frustrating to have no built-in movement code in sprites, no straightforward way to animate a sprite given a spritesheet of frames, and having to write my own score data singleton class just to keep track of the player score independently of scenes and such. It feels like Cocos2D is missing so much.

So I'm wondering whether Flixel iOS is complete enough to justify a switch. Would you recommend using Flixel iOS over Cocos2D?
Title: Re: iOS Canabalt Problems/Solutions
Post by: IQpierce on Sat, Mar 12, 2011
I don't see any signs of anyone else actually working on Flixel iOS games yet, which surprises me - but hopefully that means my game will be the first iOS game using the Flixel engine save SemiSecret's own games?

Anyway axcho, my experience with it has been good so far. I had prototyped a puzzle game in AS3 Flixel and had it in a solid/fun state just when Flixel iOS was released. A few nights later I basically did a long coding session to "port" the game - literally copied/pasted over my AS3 classes and functions and just "translated" from AS3 to Obj-C line by line - and sooner than you would think, I had my puzzle game up and running in the engine.

I've never actually used Cocos2D on iOS or any other platform, so I'm afraid I can't compare them. I can only say that, if you know how to code in Objective-C/Cocoa and are used to all the weird quirks of it (like the unbelievably clumsy syntax for manipulating NSArrays and NSDictionaries), then coding in the Flixel iOS engine will otherwise feel very pleasantly familiar.

There are some quirks; you'll see many places where the methods have odd names for Objective-C methods. Specifically where most Obj-C coders would name a function something like "attackTarget:WithWeapon:", you may see a Flixel function that looks like "attackParam1:Param2:". I realized that this was to ease automated translation from AS3 to Obj-C (which Adam has mentioned they were working on, but which they haven't released and possibly haven't finished): it makes it easier to translate an AS3 function call like "attack(trgt,wpn)".

Honestly what I miss most is the Greensock libraries (TweenLite/Max and TimelineLite/Max). Having such nice, well-animated tweens, and being able to setup and and "play" a dynamic script of events (and do it all with so few lines of code) are definitely things I miss. But that's not really Flixel-related so I'm digressing.

I did find that performance of my game was worse than I expected when I had many particles with collisions going on - but I only got that working in a rough form and I may not have been doing it the most optimal way. But I took out the collision on the particles (I didn't really need them to collide) and now it performs quite well with many particles moving onscreen at once (say 60+, with about 100 other less active sprites in the scene as well), even on my 3G and with little optimization (I'm not even reusing a pool of particles).
Title: Re: iOS Canabalt Problems/Solutions
Post by: initials on Sun, Mar 13, 2011
I don't see any signs of anyone else actually working on Flixel iOS games yet, which surprises me - but hopefully that means my game will be the first iOS game using the Flixel engine save SemiSecret's own games?

I'm working on an iOS port of my first Flixel game Picking Up Chicks Is Hard When Your Car Is A BMX. It was a moderately successful flash game, we'll see how it goes in the app store.

It does bother me about the lack of enthusiasm over the iOS Flixel release. Sure, lots of the news blogs picked up the story and it has probably been great for Semi Secret, but the Flixel iOS community seems to be lacking. Maybe we get our own board (or section of this board?) or a mailing list or something for the Flixel iOS devs to chat on.

It makes sense. Flash runs on PC/Mac/Linux and can be developed for free with Flash Develop. iOS needs a Mac, iPhone/pod/pad, and a $99 developer subscription. That's not cheap! And on top of the Objective C can be a brain bender at first.

------------

Note on the Flixel template, if you are using the fantastic Hello World template for Flixel, and you wish to use a texture atlas, there is a function called PreLoadTextureAtlases() (or similar, it's not in front of me right now), that is commented out. You need to uncomment this if you have a texture atlas (and I suggest you do!)
Title: Re: iOS Canabalt Problems/Solutions
Post by: initials on Sun, Mar 13, 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

If you use Texture Atlases, remember to uncomment out this:
 //preloadTextureAtlases();
in the AppDelegate.

Title: Re: iOS Canabalt Problems/Solutions
Post by: axcho on Mon, Mar 14, 2011
Thank you both for your responses - I'm going to go ahead with Flixel iOS!

I noticed that some of the Flixel iOS methods have descriptive parameter names, while most of them are still methodWithParam1:param2:etc. I wonder if it would be helpful if someone (me?) went through and converted all of them to descriptive parameter names.

It's just as automate-able, because you can use the parameter names. For example, this:
Code: [Select]
- (void) drawWithParam1:(FlxSprite *)Brush param2:(int)X param3:(int)Y;
would become this:
Code: [Select]
- (void) drawWithBrush:(FlxSprite *)Brush x:(int)X y:(int)Y;
What do you think?
Title: Re: iOS Canabalt Problems/Solutions
Post by: initials on Mon, Mar 14, 2011
The methods that have non descriptive names are incredibly annoying. If you were a newbie to Flixel and starting with iOS, these would be hard to get your head around.

I've already made big progress on my game using the current flixel iOS version, but if you edit those methods Flixel would become much easier to use!

I still have to refer to the headers when finding what param4 and param5 mean.

If you make the replacements I volunteer to bug test for you.
Title: Re: iOS Canabalt Problems/Solutions
Post by: axcho on Mon, Mar 14, 2011
Sounds good, I'll try revising then. I just didn't want to do that if it would mess up a bunch of people's projects, but it looks like not many people have started yet.


By the way, I just created a cleaned-up version of the Flixel HelloWorld project template that jonkk posted, plus file templates for FlxObject, FlxSprite, and FlxGroup.

Let me know if you want me to post these somewhere. :)
Title: Re: iOS Canabalt Problems/Solutions
Post by: initials on Mon, Mar 14, 2011
Those would definitely be helpful.
Post those for sure!

I've found the HelloWorld template is a great starting point. The only thing that caught me is the preloadTextureAtlas method is commented out, which I posted about somewhere on this board.
Title: Re: iOS Canabalt Problems/Solutions
Post by: axcho on Mon, Mar 14, 2011
Okay, cool - once I revise the method parameters in Flixel iOS to be more descriptive.

So should I uncomment that preloadTextureAtlas() method then? I wasn't clear on whether that is okay to call if you aren't using atlases.

Also, in the Info.plist file, the only supported orientations are Landscape left and right. Does that need to be changed, or is it better to leave that in as a default?
Title: Re: iOS Canabalt Problems/Solutions
Post by: initials on Mon, Mar 14, 2011
So should I uncomment that preloadTextureAtlas() method then? I wasn't clear on whether that is okay to call if you aren't using atlases.

This might be a question for Big John if he's still on this forum. I assume it was commented out for a reason. It's just a huge gotcha. As a newbie to Flixel iOS (and I guess we all are), it took me a while to figure that one out, so I'm just trying to warn people.

Also, in the Info.plist file, the only supported orientations are Landscape left and right. Does that need to be changed, or is it better to leave that in as a default?

Good find! I hadn't thought of that. I am building a portrait game in Flixel and haven't checked this out yet.
Title: Re: iOS Canabalt Problems/Solutions
Post by: axcho on Wed, Mar 16, 2011
By the way, I finished converting all the method names, according to this algorithm:

Code: [Select]
function FlashToObjectiveC(FunctionName:String, FunctionType:String, ParameterNames:Array, ParameterTypes:Array) : String
{
  var result:String = "- (" + FunctionType + ") " + FunctionName;
  if (ParameterNames.length == 1)
  {
    var parameter:String = ParameterNames[0];
    var parameterType:String = ParameterTypes[0];

    result += ":(" + parameterType + ")" + parameter + ";";
  }
  else if (ParameterNames.length > 1)
  {
    var parameter:String = ParameterNames[0];
    var parameterType:String = ParameterTypes[0];

    for (int i = 1; i < ParameterNames.length; i++)
    {
      parameter = ParameterNames[i];
      parameterType = ParameterTypes[i];

      if (i == 0)
      {
        if (result.lastIndexOf(parameter) != result.length - parameter.length)
        {
          result += "With" + parameter.substr(0, 1).toUpperCase() + parameter.substr(1);
        }
      }
      else
      {
        result += " " + parameter.substr(0, 1).toLowerCase() + parameter.substr(1);
      }
      result += ":(" + parameterType + ")" + parameter;
    }
  }
  return result;
}

:)

In the process, I discovered that a number of features are not implemented, such as the FlxSound class, and the FlxQuadTree (which explains why collision detection is slow!).

I'll see if I can do something about FlxQuadTree.

I also created icons for the Flixel iOS template! :D And I've been debugging the retina display issues. As it turns out, not only are there problems with portrait mode, but any zoom other than 1.0 doesn't work correctly on retina. Still working on that...
Title: Re: iOS Canabalt Problems/Solutions
Post by: axcho on Wed, Mar 16, 2011
After spending the entire day trying to fix the display issues associated with zoom > 1 and retina and iPad displays, I have decided to give up on trying to figure this out on my own, at least until I can talk with the original programmer, Eric Johnson.

Really tricky and weird stuff, and tons of permutations. Bleh. :P
Title: Re: iOS Canabalt Problems/Solutions
Post by: initials on Thu, Mar 17, 2011
Good work!
Where can I download it from?

The flixel template just got tweeted by Semi Secret! Good work guys.

Title: Re: iOS Canabalt Problems/Solutions
Post by: IQpierce on Thu, Mar 17, 2011
Need to check this thread more - as you say we Flixel iOS dev seem to be a small community. :) Maybe once we put our games out, if they have any success, the engine will get more attention among the iPhone community - as you say it seems like the existing Flixel userbase maybe isn't the most logical one for jumping over to iOS development. Objective-C is not exactly as easy to learn as AS3.

I hadn't dealt with the texture atlas issue, since my simple puzzle game uses so few textures that I haven't bothered with compiling an atlas.

Regarding the odd function names: when you think about it, it makes sense. The function names with "param1:param2" are exactly as descriptive as normal function names - which do not actually contain any descriptions of what the parameters are in the actual function NAME. Therefore when you make a function call in AS3:

takeAction("foo", 2);

When you just look at that code right there, you have no idea whatsoever what those parameters are.

This would normally be a strength of iOS, in that you could look at such a line and it would be:

[self takeActionWithName:@"foo" andNumTimes:2];

Much more informative...

BUT when you're trying to build a language-translator, you want to keep it simple; so when you come across the AS3 line above, your script has no idea how to translate that into the Obj-C line above - because from that line alone, it has no idea that it should name the parameters "Name" and "NumTimes".

Hence giving the params deterministic (but uninformative) names of Param1:, Param2:, etc., makes it easier to translate the code line-by-line.

And in AS3 etc., the only way to remind yourself what the parameters to such a function call ARE from looking at such a line is to use your IDE's dynamic info/autocomplete/whatever that tells you about the function. The real problem is that Obj-C/XCode has less great features for that case, since it usually doesn't need it.

Oh and I'm not surprised to hear that QuadTrees aren't in the iOS engine, given the slow collision and the fact that they were a later addition to Flixel AS3. If someone brings those over to AS3 it would be awesome.
Title: Re: iOS Canabalt Problems/Solutions
Post by: jonkk on Fri, Mar 18, 2011
Awesome work, axcho. Go ahead and upload it as a fork to my template on Github.  It's pretty straightforward, as far as I know.
Title: Re: iOS Canabalt Problems/Solutions
Post by: axcho on Fri, Mar 18, 2011
Thanks for the encouragement! :)

So, I just got in contact with Eric Johnson, so it looks like I'll try to keep working on these display bugs before I release the new template now. Though if you really want it right now, with the changed method names, just send me a PM and I'll email it to you or something.

As for forking your template on GitHub, I'm not sure that it would be so straightforward, since it uses a different folder structure, to include both the Project Templates and File Templates. When I finish preparing this Flixel iOS release I will probably want to start it as a new GitHub project, or maybe have Eric or Adam release it officially on theirs. We'll see. :)
Title: Re: iOS Canabalt Problems/Solutions
Post by: axcho on Fri, Mar 18, 2011
I just heard back from Eric Johnson, and one thing he said is that using FlxQuadTree was actually slower than brute-force collision detection, so he switched to brute-force. Not sure if the FlxQuadTree that is included in Flixel iOS is fully functional (if slow) or not.

FlxSound was not implemented for lack of time, but basic sound works through FlxG.play and such.

I'll let you know if I have any luck clearing out the display bugs.
Title: Re: iOS Canabalt Problems/Solutions
Post by: axcho on Mon, Mar 21, 2011
Okay, I had a chat with Eric Johnson, and now I know what to try next.

Basically, the useTextureBufferZoom option was a hack specifically for Canabalt in order to compensate for a bug in Apple's display code. I'll be taking it out, which will make things much cleaner in FlxGame. It shouldn't make a difference unless you are using OpenGL line-drawing calls in a pixelated game.

Then I'll try to come up with a better way to deal with zooming on iPad and retina displays, so you can choose to either mimic the proportions of the iPhone version or use the full resolution of the iPad to have a larger gameplay area. Right now there is an awkward way of using the zoom property of FlxGame and modelScale properties of FlxSprites to arrange this.

And maybe it would be nice to add accelerometer support as well. Any suggestions on the interface? (FlxG.accelerometer.x?)
Title: Re: iOS Canabalt Problems/Solutions
Post by: IQpierce on Mon, Mar 21, 2011
That sounds great - I always had a feeling that the method I had chosen for fixing those retina/zoom issues was a bit of a hacky workaround. (But it works for me so I'm running with it for now.)

I agree with adding FlxG.accelerometer for sure. But in Flixel's spirit of also providing many "useful but simple" other utilities, I'd suggest that you also offer a "FlxG.accelerometerFiltered.x" value that returns the value tracked with a highpass filter (probably with a separate FlxG variable to control the factor applied to that filter): http://stackoverflow.com/questions/142944/how-do-you-implement-a-highpass-filter-for-the-iphone-accelerometer

That seems to be one of those things that everyone implements on every game, so why not put it in the engine so you don't have to rewrite it over and over? And having the accelerometer seems like it would be a boon since games with mechanics like Doodle Jump could then be made more easily.

I just remembered one of my major other complaints about Flixel on iOS: Buttons. Is it just me or are the buttons terrible? I didn't see any built-in way to do a "pushed" state (I ended up hacking/reusing the "disabled" state for this - the fact that it supported a disabled state but not a pushed state was boggling for me); and its method for detecting a push are pretty hacky so far as I can see (just a "finger released over this button" check, rather than ensuring that the finger was actually pressed down on that button to begin with - and very fast 1-frame-long taps seem to not register as presses at all).

Of course there were caveats about the iOS engine and maybe this was one. It seemed like methods for a proper push-detect were in the code, but commented out. I should probably stop complaining about it and go fix it instead - but I did want to mention it in this thread as a possible caveat around using the engine. If your gameplay is heavily based on GUI buttons, you may have some issues with the engine in its current form.
Title: Re: iOS Canabalt Problems/Solutions
Post by: axcho on Tue, Mar 22, 2011
Nice thinking about that filtered accelerometer idea - I'll try that. :)

I'll also plan on looking into the buttons. Maybe the "over" state could be used for a "down" state instead on iOS?
Title: Re: iOS Canabalt Problems/Solutions
Post by: axcho on Tue, Mar 22, 2011
Thinking about possible permutations for display, on the iPhone, iPad, and retina display...

Here's what I've come up with:


Can you think of anything else?

For specifying these options, choosing between 1x and 2x art could be pretty straightforward with a "@2x" suffix for filenames like Apple uses, or "-hd" like Cocos2D. And I guess there could be a boolean flag for using iPad proportions on the iPad, when you want to actually change the layout for the iPad version of the game.

Then on top of that there is the zoom property, which could be manipulated separately. Though it would be kind of silly to use zoom > 1 at the same time as 2x-resolution retina images, but who knows...

Thoughts?
Title: Re: iOS Canabalt Problems/Solutions
Post by: initials on Wed, Mar 23, 2011
Nice thinking about that filtered accelerometer idea - I'll try that. :)

I'll also plan on looking into the buttons. Maybe the "over" state could be used for a "down" state instead on iOS?

There is demo code on the Apple developer site to do filtered accelerometer stuff with high and low pass.

Let me know if you have trouble finding it.
Title: Re: iOS Canabalt Problems/Solutions
Post by: axcho on Wed, Mar 30, 2011
Hmm, I can hardly believe it but I think I've got all the retina display issues fixed for Flixel iOS! :D

...no, wait, FlxSprite's loadRotatedGraphic method doesn't seem to be working. Though it doesn't work in the original Flixel iOS release either...

...okay, I figured out why loadRotatedGraphic doesn't work - it's because there's no support for unique bitmaps with createGraphic! Urgh...

I'll work on that next.
Title: Re: iOS Canabalt Problems/Solutions
Post by: twothreetwo on Fri, Apr 1, 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

FYI this template isn't compatable with Xcode 4 and above as Apple have changed the template format. You'll need Xcode 3.
Title: Re: iOS Canabalt Problems/Solutions
Post by: axcho on Sun, Apr 3, 2011
Hey, I downloaded Xcode 4 (no, I didn't overwrite Xcode 3!) and I've made a working test template for Xcode 4 already, so I feel pretty confident I can put one together for Flixel too.

Also, Eric Johnson found the translator code and sent it to me, so hopefully I'll have some time to try that out soon! :D
Title: Re: iOS Canabalt Problems/Solutions
Post by: twothreetwo on Thu, Apr 14, 2011
I noticed that the pause functionality in FlxG has been commented out, I guess that's because it doesn't work at the moment? Does anyone know of a way to get the game to pause (even a hack will do)?
Title: Re: iOS Canabalt Problems/Solutions
Post by: initials on Thu, Apr 14, 2011
There is a FlxButton for pause in the PlayState.
All the pause functionality is in the PlayState also. It's a little confusing to be honest. There's a variable called ReallyJustPaused. I don't completely understand it actually, but it works.
Title: Re: iOS Canabalt Problems/Solutions
Post by: axcho on Sat, Apr 16, 2011
By the way, I think I got createGraphic working for unique bitmaps, but Eric Johnson says that the draw method doesn't work either! :/

So I'm tackling that next...
Title: Re: iOS Canabalt Problems/Solutions
Post by: twothreetwo on Sun, Apr 24, 2011
There is a FlxButton for pause in the PlayState.
All the pause functionality is in the PlayState also. It's a little confusing to be honest. There's a variable called ReallyJustPaused. I don't completely understand it actually, but it works.

Thanks a lot for your help! It definitely seems to do the trick.
Title: Re: iOS Canabalt Problems/Solutions
Post by: axcho on Mon, Apr 25, 2011
Just a progress update, or lack thereof.
I've been working on game prototypes in Flixel v1.43b and starting to play with v2.50b this week, so I haven't gotten around to fixing the draw method in Flixel iOS yet...

Flixel v2.50 is impressive, and now I'm stuck between the choice of making my games in v2.50 and taking advantage of these new, powerful features, or making them in Flixel v2.43b and being able to port them easily to iPhone. :/

It should be an easy choice in favor of v2.43b, but this latest game idea would benefit a lot from being able to zoom a camera in and out...
Title: Re: iOS Canabalt Problems/Solutions
Post by: twothreetwo on Wed, Apr 27, 2011
What's everyone doing when it comes to "tweening" an objects property? In ios I've seen two methods; NSAnimation and CAAnimation but I don't think they will work with the Flixel port...or will they?
Title: Re: iOS Canabalt Problems/Solutions
Post by: axcho on Wed, Apr 27, 2011
What's everyone doing when it comes to "tweening" an objects property?

Using cocos2d instead of Flixel iOS? ;)
Title: Re: iOS Canabalt Problems/Solutions
Post by: IQpierce on Wed, Apr 27, 2011
I actually started to write a fairly elaborate Tweening class to use in my Flixel iOS project (that would dynamically execute a "setXXX" selector on an object every frame where "XXX" was the property name you provided), but I had some trouble implementing it. Then I realized that I could get 90% of the effect I wanted by using the velocity and acceleration parameters on the sprites I wanted (similar to how the Canabalt code "tweens" in the background on the opening screen). It requires tweaking of numbers to get right but I got UI elements (FlxSprites, etc.) smoothly scrolling onto screen, etc. It was a decision to "cut with the grain" and work with the strengths of the engine, even though it wasn't exactly what I wanted.

A tweening solution would be a fantastic addition to Flixel iOS - I assume that most Flixel developers, like me, just use the awesome greensock libraries for tweening on AS3. Not having an equivalent available for iOS is frustrating... if anyone knows of a Cocoa alternative that has even 50% of the features of greensock's stuff, please please share.
Title: Re: iOS Canabalt Problems/Solutions
Post by: goshki on Thu, May 12, 2011
I actually started to write a fairly elaborate Tweening class to use in my Flixel iOS project (that would dynamically execute a "setXXX" selector on an object every frame where "XXX" was the property name you provided), but I had some trouble implementing it. Then I realized that I could get 90% of the effect I wanted by using the velocity and acceleration parameters on the sprites I wanted (similar to how the Canabalt code "tweens" in the background on the opening screen). It requires tweaking of numbers to get right but I got UI elements (FlxSprites, etc.) smoothly scrolling onto screen, etc. It was a decision to "cut with the grain" and work with the strengths of the engine, even though it wasn't exactly what I wanted.

A tweening solution would be a fantastic addition to Flixel iOS - I assume that most Flixel developers, like me, just use the awesome greensock libraries for tweening on AS3. Not having an equivalent available for iOS is frustrating... if anyone knows of a Cocoa alternative that has even 50% of the features of greensock's stuff, please please share.


Just so you know, there is a Objective-C tweening library based on ActionScript 3 Tweener: http://www.tweenc.com/ (http://www.tweenc.com/). Unfortunately I cannot verify how well would it suit the Flixel iOS.
Title: Re: iOS Canabalt Problems/Solutions
Post by: IQpierce on Thu, May 12, 2011
That's great to know about goshki, thanks for pointing it out!

I don't know if I'll have a chance to evaluate it with Flixel on my current project, but we are redoing a lot of animations and menu stuff right now. If I do try it with Flixel then I'll be sure to post about my experiences with it here on the forums.
Title: Re: iOS Canabalt Problems/Solutions
Post by: twothreetwo on Fri, May 13, 2011
Hey, I'm trying to get the retina display working with my game and at the moment the image I'm appending "@x2" to is selected by default but isn't getting scaled down. Is that because I need to upscale all of my other images as well? I have about a hundred images that would need up scaling so was hoping to test with one image first :s...

My game is landscape.
Title: Re: iOS Canabalt Problems/Solutions
Post by: IQpierce on Fri, May 13, 2011
Higher in this thread, there were some posts about Retina issues. I posted the workaround I had settled on:

Quote
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.

However axcho later posted that he had consulted with Eric Johnson and fixed the Retina issues properly! (But it sounded like there were still issues with rotated textures.) Not sure what happened with that. It looks like neither that, nor anything else, have gone into the official git branch of iOS Flixel, which hasn't been updated since December: https://github.com/ericjohnson/canabalt-ios/commits/master

axcho, do you have somewhere we could pull your additions from?
Title: Re: iOS Canabalt Problems/Solutions
Post by: axcho on Sat, May 14, 2011
I do in fact have a version of Flixel iOS that would fix all your retina issues, twothreetwo.

And rotated textures work fine, just not the rotation caching (which is pointless for iOS anyway). But currently the draw method does not do anything, and there are other things which I'd like to change and clean up before I make a public release of it.

However, I'd be glad to send you what I have - just PM me your email address.
Title: Re: iOS Canabalt Problems/Solutions
Post by: ExpertNovice on Mon, Jun 27, 2011
I just wanted to encourage everyone hard at work on this project.  You guys are gonna put flixel firmly on the map when people start making a buck off of it.

Flixel is just so quick! And my brother always says the iPhone is the best platform, everyone has one. :D

Seriously guys, nice work.
Title: Re: iOS Canabalt Problems/Solutions
Post by: initials on Mon, Jun 27, 2011
Thanks!

I would be great to see the same level of community input as the Flash version but not everyone can buy all the Apple stuff to start making games. It's really quite expensive when you add it all up.
Title: Re: iOS Canabalt Problems/Solutions
Post by: goshki on Tue, Jun 28, 2011
It's really quite expensive when you add it all up.

And this is the main reason I'm still not developing iPhone games. :(
Title: Re: iOS Canabalt Problems/Solutions
Post by: racingspider on Fri, Jul 1, 2011
Just joined and I'm wondering if the port to iOS is complete enough to make a full game - or are there major features lacking?

I'm currently developing with Cocos2d (which is great), but if Flixel can look the way I've seen so far, I might jump on that.
Title: Re: iOS Canabalt Problems/Solutions
Post by: initials on Fri, Jul 1, 2011
I'm a huge Flixel fan. I have tried Cocos2D and I will say that it has more features and more community support.

Flixel is definitely complete enough to make a full featured game. Check out the source code to these games:
* Canabalt https://github.com/ericjohnson/canabalt-ios
* Picking Up Chicks Is Hard When Your Car Is A BMX https://github.com/initials/Picking-Up-Chicks-Is-Hard-When-Your-Car-Is-A-BMX
* Mode https://github.com/initials/Mode-iOS
* FlxiOSInvaders (not a full game) https://github.com/initials/FlxiOSInvaders

Also I presume Gravity Hook is a Flixel game, but no source code.

If you are comfortable with Objective-C and a little OpenGLes then extending Flixel iOS' capabilities is for you! We'd love people adding features and sharing code!

Just joined and I'm wondering if the port to iOS is complete enough to make a full game - or are there major features lacking?

I'm currently developing with Cocos2d (which is great), but if Flixel can look the way I've seen so far, I might jump on that.
Title: XCode 4
Post by: racingspider on Fri, Jul 1, 2011
If you're using XCode 4, you may need to tweak a setting to get it to run.

See this:
http://www.weston-fl.com/blog/?p=2351 (http://www.weston-fl.com/blog/?p=2351)

I look forward to seeing what we can do with this engine on the iOS... though I know nothing about it!
Title: Re: iOS Canabalt Problems/Solutions
Post by: walkerman on Sun, Aug 7, 2011
Just a progress update, or lack thereof.
I've been working on game prototypes in Flixel v1.43b and starting to play with v2.50b this week, so I haven't gotten around to fixing the dra (http://www.craze4android.com/categories.php?category=Android-Phones)w method in Flixel iOS yet...

Flixel v2.50 is impressive, and now I'm stuck between the choice of making my games in v2.50 and taking advantage of these new, powerful features, or making them in Flixel v2.43b and being able to port them easily to android tablets (http://www.craze4android.com/categories.php?category=Android-Tablets). :/

It should be an easy choice in favor of v2.43b, but this latest game idea would benefit a lot from being able to zoom a camera in and out... 2945abc45 0808
Title: Re: iOS Canabalt Problems/Solutions
Post by: ali hafizji on Mon, Aug 8, 2011
Hey guys,
       I just started looking into flixel and I looked at the cannabalt code. My problem is that when I tried to change the Player sprite sheet to my own player. The image appears to be extremely pixelated. Is there any reason why this is so?
Can I remove the pixelation so that the image quality persists.

Thanks
Title: Re: iOS Canabalt Problems/Solutions
Post by: initials on Mon, Aug 8, 2011
Hey guys,
       I just started looking into flixel and I looked at the cannabalt code. My problem is that when I tried to change the Player sprite sheet to my own player. The image appears to be extremely pixelated. Is there any reason why this is so?
Can I remove the pixelation so that the image quality persists.

Thanks

What device are you using?
Can you post your sprite sheet and a screen shot?

The first thing that comes to mind is that Flixel scales pixels and keeps hard edges. So if you start with a small sprite sheet, it will hold it's hard pixel edges as it gets scaled.