A recent game called the HTML5, reported to have been done using the technology of the cat. HTML5 's cross-platform excellent features are very good. For the shortage of manpower, insufficient technology, the choice of HTML5 technology to achieve cross-platform dream is really good.
Recently looking at Coco2d-js this cross-platform game development framework. Very good, wrote a demo program for everyone to participate in the test.
/** * Created by Caicai on 14-7-27. */var ball = cc. Sprite.extend ({velocity:null, ctor:function () {this._super (res). Ball_png); var size = Cc.director.getWinSize (); This.x = SIZE.WIDTH/2; This.y = SIZE.HEIGHT/2; this.velocity = CC.P (10,10); }, Update:function (dt) {this.setposition (Cc.padd (This.getposition (), Cc.pmult (this.velocity, DT))); This.checkhitedge (); }, Checkhitedge:function () {var pos = this.getposition (); var winsize = Cc.director.getWinSize (); if (pos.x > Winsize.width-this.width | | pos.x < this.width) {this.velocity.x *=-1; } else if (Pos.y > Winsize.height-this.height | | pos.y < this.height) {this.velocity.y *=-1; }}); var gamelayer = cc. Layer.extend ({_ball:null, _touchbeginat:null, Ctor:function () {this._super (); This._ball = new ball (); This.addchild (This._ball); Cc.eventManager.adDlistener ({event:cc. Eventlistener.touch_one_by_one, Swallowtouches:true, OnTouchBegan:this.onTouchBegan, on TouchMoved:this.onTouchMoved, onTouchEnded:this.onTouchEnded}, this); This.scheduleupdate (); return true; }, Update:function (dt) {this._ball.update (dt); }, Ontouchbegan:function (Touch, event) {This._touchbeginat = Touch.getlocation (); Console.log ("Begin") return true; }, Ontouchmoved:function (Touch, event) {}, Ontouchended:function (Touch, event) {Console.log ("end") var endAt = touch.getlocation (); if (This._touchbeginat = = null) return true; var velocity = cc.psub (endAt, This._touchbeginat); Event.getcurrenttarget (). _ball.velocity = velocity; return true; }}); var ballscene = cc. Scene.extend ({layer:null, onenter:function () {this._super (); This.layer = new Gamelayer (); This.AddChild (This.layer); This.schedule (this.update, 0); }, Update:function (dt) {this.layer.update (dt); }});
Not yet intact, there is room for improvement.
Coco2d-js The rolling Ball of the demo program