News for hackers. Stuff that matters.
Re:I made an iPhone game with PhoneGap and won't do it again by djsumdog on Saturday November 26, 2016 @05:08PM (#13046174)
He developed it in PhoneGap and didn't release the Android version? :(

I've heard a full engine like Unity is a lot better for designing games across mobile platforms. I've heard cross platform mobile development is a pain, but if you're going to do it, use the right too for the job. Don't develop a shopping app in a game engine and don't try to implement a game engine in something meant for a shopping app.

Re:I made an iPhone game with PhoneGap and won't do it again by bayonetz on Saturday November 26, 2016 @06:01PM (#13046510)
This is worth repeating; use the right tool for the job. Phone gap is actually pretty great for the scenario where you need a simpler info screen app to be cross platform from day one. I made a personal app that way and it worked out great. The author sort of conflates Phonegap being bad for games for Phonegap being bad for apps in general. I think a lot of smaller companies would be better of going the hybrid route for things like food ordering or boutique shopping, etc. but there is this serious bias against it that I think 9 out of 10 times is more tribal/religious than for actual technical limitations.
Re:I made an iPhone game with PhoneGap and won't do it again by rudedogg on Saturday November 26, 2016 @07:47PM (#13047000)
> there is this serious bias against it that I think 9 out of 10 times is more tribal/religious than for actual technical limitations

I always feel like it's the opposite. People who haven't tried it themselves will say to use Cordova for everything, but once you start you notice the performance issues right away.

It's frustrating because a lot of freelance jobs I see are asking for Cordova experts, and it's pretty obvious they're going to end up with a shitty app. But, no one is going to tell them that. They'll spend all their money getting a Cordova app made, and then look for a native developer when they realize how bad it is and have no money left.

For background, I was learning JS development, and was really excited about Cordova. I thought Moore's law had finally put web based mobile apps (mostly) on par with native. But it's just not true, and I don't think it will be for a long time. I wish people would be more honest in their documentation about the limitations of things.

Re:I made an iPhone game with PhoneGap and won't do it again by SomeCallMeTim on Saturday November 26, 2016 @11:16PM (#13047683)
>People who haven't tried it themselves will say to use Cordova for everything, but once you start you notice the performance issues right away.

I've developed a half dozen apps in Ionic Framework, and they all operate at a silky smooth 60FPS. I don't end up with performance issues because I'm:

* Using CSS for animations

* Not using JQuery for things you should never use JQuery for in 2016 because they're too slow on mobile

* Not piling on tons of verbose frameworks to accomplish every little thing and therefore slowing down the JavaScript engine as it ends up with multiple megabytes of code

* Limiting asset sizes so we don't overrun mobile memory limits

* Generally optimizing the code so that I'm not wasting time or creating 16 intermediate arrays in every data conversion/manipulation because the functional approach looks so pretty

I understand you were "just learning JS development." It may actually (ironically) take more of an expert to get good performance out of Cordova than it does to produce a decent native app.

But everything I did above should also be standard practice for creating any web pages, since otherwise performance will in fact be crap on mobile. So it's really just web development best practices.

No, it's not that there are limitations in Cordova. It's that writing web pages for mobile is harder than for desktop, but that when you do it right, it makes for a good app experience as well.

Not to mention React Native and NativeScript, which will get you full speed on mobile with native controls.

Re:I made an iPhone game with PhoneGap and won't do it again by rudedogg on Sunday November 27, 2016 @12:09AM (#13047833)
I'll be a little more detailed. What I tried to do was make a game using Phaser. I didn't get past creating the loading and menu scenes before I starting noticing really bad sluggishness when first loading, etc. If you let it sit for 10 seconds then things mostly smooth out, but you still have the frame rate randomly drop, etc. I had done so little there was nothing to optimize, it was just the barebones to get something on the screen. And I didn't even try it on mobile, this was using my desktop/laptop.

I see the same thing with CSS3 animations. There's this weird jerking, even on something simple like this: http://www.w3schools.com/css/tryit.asp?filename=trycss3_anim... . When I enable the FPS meter I see drops to 30FPS.

Also, I hadn't heard of Framework7 mentioned in another comment, so I checked it out. The demo apps I tried (http://framework7.io/apps/) have issues on mobile. I just feel like it's unfair to new developers who are going to invest a lot of time before they figure out hybrid apps have issues. I know people want to market/highlight how great their framework is, but it causes us all grief. We should be more upfront about what works well (CRUD apps), and what doesn't (games, animations, custom UI).

I don't know enough about React Native to comment.

Re:I made an iPhone game with PhoneGap and won't do it again by SomeCallMeTim on Sunday November 27, 2016 @05:45PM (#13052068)
I'm working with Phaser on an app that needs to be mobile, but I'm regretting not using PIXI directly.

See: http://www.goodboydigital.com/pixijs/bunnymark/ -- click or touch to spawn bunnies.

Run it on mobile. On my Nexus 6 it stays pretty smooth around 10-15k bunnies, sometimes more. I've seen it glitch as thousands of new bunnies are added at once, but in a well-written game you'd create a "bunny pool" and pre-create all of them so that you could add them without as much overhead.

It's actually a bit jerky on Firefox on my "ultra low power" laptop, despite having a recent Intel i7 CPU, but Chrome is smooth up to 10K bunnies. On my gaming computer, heh, I can go over 100K bunnies without it dropping below 60FPS. That's a lot of sprites, period.

At some point I'll probably port my game from Phaser to PIXI. Like I said, I'm stuck using a browser for at least part of my game. If I were creating a 2d game that didn't require a browser, I'd probably use something else: Unity, maybe, or I'd look around at the other 2d and 3d engines out there to see what's available. I also have an existing 2d engine that I might bring up to date.

In your sample on w3schools, I ran some profiling, and it's firing off dozens of JavaScript callbacks per second, doing who-knows-what. Analyics, probably? Also, as mikewhy pointed out in a sibling comment, transform:translateX() gives you hardware acceleration. Otherwise it has to rebuild the DOM on Every Single Frame. I pulled the code to a local server without the w3schools extra cruft and it was much better, but still not perfect. Converting to using tranform:translateX() made it silky smooth.

In any case, good luck.

Re:I made an iPhone game with PhoneGap and won't do it again by mikewhy on Sunday November 27, 2016 @04:37PM (#13051689)
In that example they are animating the "left" prop, which won't be hardware accelerated. Using "transform: translateX" will allow the animation to be hardware accelerated.
Re:I made an iPhone game with PhoneGap and won't do it again by wingworks on Saturday November 26, 2016 @08:17PM (#13047131)
Agreed, when I first heard about PhoneGap it sounded amazing, then I tried and the performance hit is just too great, even for simple apps. Maybe in the future it'll be better, but not yet.
Re:I made an iPhone game with PhoneGap and won't do it again by ahmetkun on Sunday November 27, 2016 @02:31AM (#13048186)
This is what people have been telling since 2010. In the future with faster phones the difference will be negligible or something along these lines.
Re:I made an iPhone game with PhoneGap and won't do it again by LeoNatan25 on Sunday November 27, 2016 @06:23AM (#13048679)
This reasoning has been a bust for many years. As hardware specs go up, so doES the native UI become more demanding. Compare iOS 6 to iOS 10, from translucency to animation complexity to text rendering complexity. Now take web technologies and try to emulate the same complexity - it becomes more and more prohibiting. If anything, it gets worse and worse, not better.
Re:I made an iPhone game with PhoneGap and won't do it again by fjrieiekd on Sunday November 27, 2016 @12:17PM (#13050187)
So battery usage doesn't matter to you?
Re:I made an iPhone game with PhoneGap and won't do it again by TillE on Saturday November 26, 2016 @05:25PM (#13046270)
This is good advice. From the article:

> So I added a few more entities to the world. Suddenly, it was running at around 30 FPS. Yikes.

If your framework can't do simple OpenGL draw call batching, it's unsuitable for games. I'm not a huge fan of Unity (though it'll be a lot better when their version of C# is finally updated), but it's probably the best thing available for cross-platform game development.

Re:I made an iPhone game with PhoneGap and won't do it again by kennu on Saturday November 26, 2016 @05:25PM (#13046269)
Personally, after playing around with all kinds of game engines and frameworks, I always go back to Unity. It has a lot of warts and issues, but for me it's the most productive way to focus on actually creating games.
Re:I made an iPhone game with PhoneGap and won't do it again by Tobias42 on Saturday November 26, 2016 @06:50PM (#13046733)
Have you tried SpriteKit? I chose SpriteKit with Swift for my first game and like it quite a lot, but I keep wondering if it was a good choice to limit myself to iOS.

What I'm interested in mostly is if I at least got a significant performance gain from chosing SpriteKit over Unity.

Re:I made an iPhone game with PhoneGap and won't do it again by AlexeyBrin on Saturday November 26, 2016 @07:26PM (#13046911)
Try Cocos2d-x which is a multiplatform C++ implementation of the old Cocos2d-iPhone, SpriteKit was, at least partially, inspired from Cocos2d-iPhone.
Re:I made an iPhone game with PhoneGap and won't do it again by wslh on Saturday November 26, 2016 @10:15PM (#13047489)
The same author is working in Cocos2d-x and Cocos2d-iPhone, although Cocos2d-x is not owned by him.
Re:I made an iPhone game with PhoneGap and won't do it again by AlexeyBrin on Saturday November 26, 2016 @10:22PM (#13047506)

    The same author is working in Cocos2d-x and Cocos2d-iPhone
That was in the past, AFAIK Ricardo works only on Cocos2d-x now. Cocos2d-iPhone is community driven now.
Re:I made an iPhone game with PhoneGap and won't do it again by morbidhawk on Saturday November 26, 2016 @07:57PM (#13047046)
I'm not sure about the performance differences, but there was a different reason that kept me away from switching to Unity. I've built a couple games in SpriteKit doing it entirely programmatically in code and realized Unity is not setup to work that way at all. If you have experience using SpriteKit Scene Editor then you might not be bothered by that, but I was. Instead of Unity I'm using MonoGame now since it is meant to build the game using just code and I find it was a lot easier to jump into using my existing knowledge from SpriteKit
Re:I made an iPhone game with PhoneGap and won't do it again by codinghorror on Sunday November 27, 2016 @12:38AM (#13047905)
The problem is that JS perf is so much worse on Android, and adding insult to injury, the single threaded perf of the very fastest Android devices are less than half an iPhone 7. Worse still, Apple devices get upgraded aggressively, whereas Android devices don't, so the long tail of very old very slow devices (mobile devices age in dog years) is enormous. Sad but true.