Optimizing Flash for the iPad
You might know that I am making a game for the iPad and it’s nearly done. The thing is, I also want to publish it on the web, you know, make money from sponsorship too. Actually, I think it might be the only way I make money with the game as the iPad app market seems really hard. Plus it will also cost me money to publish in the Apple app store (developer account), so I think I might be loosing money going that way. Anyway, I was testing my game for the web first and everything was working fine. I tested on the iPad after and that is when things started to get hairy.
Yeah, an iPad (iPad 2) is not a full fledged computer (funny to say this considering my first computer was a 486), so it is not as fast. Well I have seen some pretty crazy shit on the iPad, like the Dead Space game so I guess it can be pretty strong. This only means that the Flash player isn’t that great on it, probably because it doesn’t use the GPU. So as I was testing my game on the iPad, it started out working really great, but as the game went on, more and more objects got drawn onto the screen and that is when the performance started to go down. So I set out to optimize my code.
Object pooling
Object creation in Flash is an operation that is costly and since I hadn’t optimized anything yet, I was recreating every object on the screen every frame. There is a possibility of having 240 objects on the screen at the same time, so that’s a lot of object creating every frame. To minimize this, you can do object pooling, which is having a pool of already created objects and change their properties instead of creating new ones. I did just that and it went really fast to implement. The thing is, when I tested it on the iPad, it made no difference at all.
Blitting
Another thing that is heavy on the CPU in Flash is updating graphics, so I tried to optimize that part. Blitting is a technique by which you compress all your visual into only one Bitmap that you draw on the screen. So instead of having multiple display objects being redrawn (in my case 240), you only have one. Read more about blitting here. Blitting doesn’t fit well with every project (like those relying on vector graphics) , but mine was based on Bitmaps and didn’t have a lot of rotations (it did, but only 90 degrees one) so I could easily do it. I was pretty sure that this would help a lot, but it actually did nothing noticeable. I was a bit baffled here, maybe my redrawn zone is too big… It is a game for iPad so I have a full resolution of 1024 x 768, maybe that is too heavy for the Flash Player.
Code Optimization
So if it wasn’t the creation of objects or the graphics, than maybe it was the code. I had used Arrays everywhere cause it is just simpler to use than Vectors, so I changed them all. I also did some loop optimization and replaced some divisions by multiplications ( like /2 to *0.5). Also didn’t change anything…
Last Resort
My last resort was to change the game dynamics so that the game is less intensive on the CPU and that is the only thing that made any impact on performance. My game is a puzzle, so I removed 3 rows and 1 column from it thus reducing the possible maximum number of object on the screen (and also the redrawn region size, and probably also the number of computations) by 20%.
Conclusions
I’m pretty sad at this point, changing the game dynamics to optimize is not a really good decision, it’s kinda like saying let’s make the game less fun to make it run faster. What I liked about Flash is that I could compile for the web, iOs and Android with limited changes (in this case all I changed was different layouts based on size (height and width) of the game). Turns out it is not fast enough on iOs (iPad). Maybe when they put Stage3D on iOs that will do it, but till than there is no true cross development platform. I meant to look into Corona, but it does only mobile. And I really don’t want to fall into the HTML5 mess. I would really like to hear about a dev story about HTML5 and a game built for web and mobile and most importantly how much time it took to do.
Happy 2012!
4 years I have been writing on this blog. I am kinda proud, but I do have to ramp up the pace. It’s been 4 months since I left B-Reel and let’s say that I have been semi-productive. I have not been doing nothing but I have not worked 7 hours everyday, not even 5 like I wanted. Kinda hard to wake up early when you are your own boss. Also, I only wrote 4 posts in 4 months so the traffic to the site diminished a bit but nothing too serious.
So here we go for 2012, I am about to finish a personal game and a contracted game, so that is good. I have another game that is about 45% completed, so I will be working on that next. My goal is to complete 3 personal games this year, not including the one that is almost finished. Don’t know if I’ll be able to make it, but it sure would be good. I would also like to post 2 times a month, to be realistic, more would be better but I am not sure I will have the material to write as much. I will probably also try to look into HaXe, I am very curious about this tech, what it can do and how to use it so we will see.
So happy 2012 for everyone!
My game on a iPad, my pilgrimage
YEAHH! Pretty nice is the feeling you get when you see your game for the first time on the medium it is supposed to be. Yesterday I dwelled in the mysteriously complicated world of signing applications for the Apple App Store. 6 hours it took me to finally get my game on my tablet ( by the way I didn’t buy the iPad, I won it
). I would say that 2/3 of that I was stuck in Apple developer center where you have to do numerous steps and get many files in order to sign your app / game. The last third came from converting one certificate to something Flash can use to compile a .ipa file.
For that step you can either do it on OSX or on Windows differently and since I have both installed on my machine, I thought I would do it the easy way ( what I thought would be) on OSX, but for some reasons Keychain access didn’t seem to export me the right things. So I had to do everything using OpenSSL on Windows, which after a little tweak, worked like a charm. Follow these instructions from Adobe to do so: generate signing request, convert certificate to .p12.
So with that done, I was set to compile my Flash game into an iOs app. This proved also more complicated than what I thought. My game was built using FlashDevelop, but I have Flash CS5.5 so I thought it was just a matter of setting my main class as the document class of a new fla. Turns out the Flash compiler is different from the Flex compiler and it started throwing me a lot of weird errors. I have to admit my project is a bit weird too (I lost one fla, so I had to decompile one file but I couldn’t get the font out of it, so I have 2 swc that have symbols in common), but it should have worked. Anyway, you don’t need Flash to compile to iOs. I downloaded the new Flex SDK and the latest AIR SDK (4.6 and 3.1) and used those templates for FlashDevelop and it worked mighty fine. Funny thing, my game was already compiled using the Flex 4.5.1 SDK; not AIR (I am not using anything special) and not the latest SDK, but I didn’t have to recompile it, I just packaged it and it worked fine. I wonder if I use the AIR compiler instead if it would run faster???
Adobe stops Flash mobile dev (or how I finally found something to write about)
Haha, yeah, haven’t wrote much lately, not that I don’t want to, I just don’t have anything to write about, but now Adobe did give me something. So, they will stop working on the mobile version of the Flash player. A lot of people talked to me about it this morning, with big grins in their faces, like saying: “See, see, it’s dead already”. Damn people are clueless sometimes, haha. I don’t think it’s that big of a deal right now, right now I mean, but I think it could mean way more in the future.
Ya, right now, on a phone, with its screen size, it is not the best way to consume Flash rich experiences like Aldo Shoes for Life. The screen is too small, you don’t get as much as what you get on the desktop. But the same goes for HTML rich experiences; would you interact with the Wilderness Downtown on a mobile phone? I don’t think so. Where I think it is more problematic, is on tablets, where the screen has more real estate. Most rich experiences would work pretty well on that. The problem is that the only tablet worth the name is the iPad (well that will change in time) so no one could see rich flash experiences on them and realize that it is working quite well.
So short term, no biggie, doesn’t really change much, nobody was doing Flash sites for mobile anyway. Long term, it’s hard to say. Phones are gonna get bigger screens that I am sure off, be it foldable screens or some other innovation, screens will get bigger. Also, there will be more tablets out there and their uses will be more defined. For that alone, it would be nice to have Flash on mobile. Then, there is the new mobile application paradigm, where instead of building web experiences and apps, you build native apps. I don’t know if this is a trend that will last forever. I mean the desktop is slowly moving toward web and cloud, shouldn’t mobile do the same too? So I think it might be a mistake to stop mobile development.
But I also understand a bit, I mean Adobe was already developing 3 Flash players : PC, MAC, Linux. Now with mobile, it would have to develop one for every mobile operating. So here it is, my views on the topic, one more in the sea of web.
Workin and playin
Posted by zedia.net in Games, Uncategorized on October 16th, 2011
I have been working, on my projects and on paid work, and it’s been good. My own project is moving along fine and I should have something new to show pretty soon. As for work, well it’s going. I haven’t got much to write about, what about is mostly some little quirks inside of Flash Professional itself.
But I want to write about this little game I found: The binding of Isaac. I am pretty sure it was made in Flash and a demo of it can be found on Newgrounds. It’s a pretty well done game and it reminds me of the dungeons in Zelda and Kid Icarus. It’s got that same feeling, with upgraded graphics. The lore is also pretty funny, it’s got a really skewed sense of humor but everything fits and I find it very funny. Now the concept is really simple, but because they created so many power ups (each with their own hilarious visual) it makes it so that every run of the dungeon is different and it adds a lot of replayability. Anyway, that is the kinda game I aspire to make. I advise you to go buy it on Steam, it’s only 5$.
On my own; two weeks after
So from my last post you know that I left B-Reel and that I am back in Montreal. I haven’t posted much because I haven’t been working much. It’s been really good times, but not that good work wise. There are a lot of reasons for that, but mostly because I am in what I would call a transition state. I am not living in my apartment yet (September 1st) and that causes my lifestyle to be quite different (lots of travel time, no desk, no office, no gym, lots of food). But I did get some work done just not that much as I could have.
Building games is not building websites
It is quite different to be franc, mostly because the challenges are different and because of that I haven’t found much topics to write for this blog. I think it is my fault a bit, I chose to do a game that is very close to an application and doesn’t rely so much on the graphics. I thought this would be a better idea, because I could save a lot of time by doing so. The good thing also is that it is based on a lot of interfaces (visual, not code) and I website building made me very good at making interfaces. The challenge that I face is more about where to put the logic and how to organise my code.
Finding how to make it work (or make me work)
My trick right now is to go to a coffee place and work from there. That has been working quite well for now, but starting Tuesday I will have an office space and I really look forward to it. Working from home is just not doing it for me, I watch TV or do some other random stuff that I won’t do if I am in a working place. Now all I have to figure out is how to wake up earlier in the morning.
Goodbye B-Reel and on to the next one, again
Yeah, big news, I will be leaving B-Reel and New York and going back to Montreal mid-August.
But why o why?
Well, really nothing against B-Reel, these guys are awesome, but it has more to do with the realization that I might not be at the right place. I mean B-Reel is the best production company in the world and they paid me a trip to London and the Alps, so if I’m not happy there, maybe the problem is not them. But I do have a lot of gripes with the Advertising Industry in general, a lot.
First, the more I do it (build marketing experiences) the more it grows futile. Secondly, it’s a pretty savage industry if you consider how it handles it’s people. Yes it pays well, but the hours and the pressure are pretty high, which is very alienating. I don’t think I have any power to change this and I don’t feel the urge to participate in this system. Thirdly, I’m pretty tired of being told what to do, part of that comes from the fact that this industry is stuck in a old model where the creative director is the rockstar and tech people are tools (it is getting better), but also as long as there will be a client there will be someone to tell you what to do.
So what is next?
Nothing really, or everything I guess. Haha, if I wanted to be more vague I wouldn’t know how to write it. I won’t be getting a job, that I know for sure. It’s a funny thing to tell people, they don’t really get it. The thing is, I have a plan, now I just have to do it. I want to make games. It’s been something I have been wanting to do for a long time, I even started multiple ones (mutant farm, doodle destroy, a nameless rpg) but never got to finish any of them because of time and life constraints. Well now I am giving myseld the time to finish them properly. While in New York, I was able to put some money on the side, so it only make sense that I return to Montreal, where life is cheaper, and spend some time doing personal projects. I am at a good place in my life to do so.
The plan in detail
Basically rent a desk somewhere not to expensive and get things done 7 hours a day, go to the gym, take some mix martial art class, pass my driving licence test (cause the joke as gone on long enough, I’m 30 and I don’t know how to drive), write more on the blog and finally maybe do some freelance if I really need to put bread on the table ( I think I should be ok on that side, at least for 6 months). If I can do that and get a game or two out, than I don’t care about the outcome, the worst that could happen is that I find another job, but let’s hope it doesn’t come to this haha!
Wonka – The Imagination Room
My latest project was for Wonka and is basically a 360 video player. It was fun and little and made me explore a bit. I got to play with Stage3D to compare the speed, plus I tried the new native mouse cursor (MouseCursorData). None of that made it in the final site but still was fun to try out. So here you go explore the Imagination room and don’t forget to look around:
A language of my own
Today I was checking out an introduction video to CoffeeScript and it got me thinking about programming languages in general and where they were heading. The thing is, I think I would go in a different direction. Haha, that’s a pretty bold statement and I don’t know that many programming languages to be frank, but the last two I checked out, Python and Coffee Script didn’t have the same values that I think a future programming language should have.
You see if I look back in time ( with my time machine glasses) at first there was byte code, which was the summum of being cryptic, after that there was assembly code, which I manage to pass the class by acting as if I knew wtf it was meaning. C code was already more readable but still pretty hard to juggle with and I ended up with Java / ActionScript / C# which were the most readable in all the languages I had learned. When I say readable in all this I mean closer to the English language. That for me should be a primary value when creating a new language. I think the more readable a programming language is, the less barrier there is to creating code. You wouldn’t need to translate what you think into something else, you think, talk, write and program in the same language, that would be the best I think.
There is all lot of really easy thing we could do to turn Java into something already more readable without changing the syntax. Most of it would just be replacing shortcuts like for if statements “==” would be “is equal to” so
if (myCat == yourCat)
would become
if (myCat is equal to yourCat)
I mean this is a pretty simple example, but push this further and say we add a lot of these changes where we remove symbols like > < = / ! || && and put words instead, I think it would make code really easy to read. I think that if it is easier to read, it is easier to grasp and if it is that way you can build more complex programs more easily. When all those simple swaps are done we could work on the syntax to make it more like English and then we would have a new programming language. I would like to reclaim the dot (“.”) to mark the end of a sentence like Latin languages.
So yeah I think we should create a new programming language where you have to write more code to get things done but that has less abstractions. That might sound stupid but I think it doesn’t matter, where the language gets longer to write the code editor should pick up and do code completion to speed things up, like FDT does so well for ActionScript.
Anyway, I will probably never do so because I am not a compiler genius, but I think it would be great to head in that direction and see where it leads. Anyone thinks the same? Anyone knows of a languages that tries to do this as its primary objective?




