★ TouchArcade needs your help. Click here to support us on Patreon.

writing games in JavaScript Vs Cocos2d

08-13-2009, 06:28 AM
#1
Joined: Aug 2009
Posts: 12
writing games in JavaScript Vs Cocos2d

hey..
I'm considering whether to develop my 2d game by using:
a. cocos2d for iphone
b. JavaScript (and connecting the player to my website).

what other downsides(besides the need for an internet connection..) are there for using javascript as my main code for the game?

It seems that javascript can run really nice&cool 2d games .. so why not use it? why should i prefer cocos2d?

please share your experience..
cheers.
08-13-2009, 06:51 AM
#2
Joined: Dec 2008
Location: The Land of The Rising Sun
Posts: 146
First of all, JavaScript is a computer language but Cocos2d is not. Cocos2d is an engine for making games. It isn't really a programming language; it is a tool to help programmers make games more quickly.

The main programming language of the iPhone is called Objective C. You can also use other programming languages, like C or C++ to write games for the iPhone.

One reason why you would not want to use JavaScript is because it is very, very slow compared with these languages. It also does not have many of the features of these languages. So, for example, if you wanted to have an image of a ball rolling across the screen based on how someone's finger touched the screen...that would be very hard, if not impossible, to do in JavaScript. It is something you should do with Objective C or another programming language.

Also, if you make a game with JavaScript on your website, people who do now have the internet can't use it. You also can't sell it in the App Store.

To put it simply, JavaScript is really made for doing web sites. You can make simple games with it, but it is not nearly as powerful as languages like Objective C.

Developer of Petri. Available now on the iTunes Store.

These days I work with Tonchidot on Sekai Camera.

08-13-2009, 10:49 AM
#3
Joined: Nov 2008
Posts: 128
actually js isn't a bad idea if you know it. Sure you won't be doing 3d and really amazing OpenGL things, but you might not need them.
Js and HTML could be saved locally in a native app, executed it a webkit view. Could remotely update your code where that'd be impossible without a scripting language.
With css3 and now html5 you can do amazing stuff. Things you can't do like sound effects etc could be hooked via your app "wrapper".
That could leave you with a VERY portable game that could probably move to mojoSDK/pre easily.





Quote:
Originally Posted by gillygize View Post
First of all, JavaScript is a computer language but Cocos2d is not. Cocos2d is an engine for making games. It isn't really a programming language; it is a tool to help programmers make games more quickly.

The main programming language of the iPhone is called Objective C. You can also use other programming languages, like C or C++ to write games for the iPhone.

One reason why you would not want to use JavaScript is because it is very, very slow compared with these languages. It also does not have many of the features of these languages. So, for example, if you wanted to have an image of a ball rolling across the screen based on how someone's finger touched the screen...that would be very hard, if not impossible, to do in JavaScript. It is something you should do with Objective C or another programming language.

Also, if you make a game with JavaScript on your website, people who do now have the internet can't use it. You also can't sell it in the App Store.

To put it simply, JavaScript is really made for doing web sites. You can make simple games with it, but it is not nearly as powerful as languages like Objective C.
08-14-2009, 07:46 AM
#4
Joined: Mar 2009
Location: Singapore
Posts: 1,770
Send a message via AIM to kohjingyu
Oh and btw, you don't have to connect it to your website. You can access a local .js file. I think.
08-14-2009, 11:18 AM
#5
Joined: Apr 2009
Location: Pennsylvania
Posts: 1,006
For games that don't need accelerometer, multitouch, or 3d, JavaScript is underrated as a vehicle for creating games on the ipod/iphone. You can actually do some fairly compelling stuff in JavaScript - there were a number of excellent proofs of concept before the AppStore emerged, including a high quality Bejeweled port.

The big downside is that without a native iphone shell you have no good way to make money from a pure web app, and you probably won't get much attention, either. Even if you don't care about making money, users are accustomed to using the AppStore to find and play free games.
08-14-2009, 01:26 PM
#6
Joined: Feb 2009
Location: Minneapolis, MN
Posts: 122
Don't forget about phonegap! (phonegap.com) It'll let you get access to a lot of that stuff that js doesn't normally have access to (accelerometer, etc.). Also, it's a cool project.

I'm not sure I'd ever write a game in .js, but more and more it's actually feasible in terms of performance and stuff. I saw a perfectly good tetris implementation not that long ago.

My games: ActionChess, Oppo-Citrus & Catchup
blog: http://chesstris.com/ twitter: livingtech GameCenter: grid
08-15-2009, 03:00 AM
#7
Joined: Dec 2008
Location: California, USA
Posts: 2,143
You can program in Unity3D using a form of javascript, or a number of other languages. It is compiled to something many times faster when the game is ...uh...compiled.
08-17-2009, 01:45 AM
#8
Joined: Aug 2009
Posts: 12
Hey,

Thank u all for the replies.... very interesting

I guess I'll need to see if JavaScript capabilities meet my games needs..


Does anyone know any iphone games done using JavaScript?


Cheers