Hashasm Posted January 10, 2017 Share Posted January 10, 2017 Can someone please tell me where can i find melonjs 4.0 doumentation Quote Link to comment Share on other sites More sharing options...
Parasyte Posted January 10, 2017 Share Posted January 10, 2017 Documentation is linked on the website and the README. Here's a direct link: http://melonjs.github.io/melonJS/docs/ Quote Link to comment Share on other sites More sharing options...
Hashasm Posted January 10, 2017 Author Share Posted January 10, 2017 The syntax's given in the documentation is different from what is there in melonjs 4 version. For Example:- syntax givin for pointer function is // onActivate function onActivateEvent: function () { // register on the 'pointerdown' event me.input.registerPointerEvent('pointerdown', this, this.pointerDown.bind(this)); }, // pointerDown event callback pointerDown: function (event) { // do something .... // don"t propagate the event to other objects return false; } but this syntax is not working with my ver 4.0.. Quote Link to comment Share on other sites More sharing options...
obiot Posted January 10, 2017 Share Posted January 10, 2017 as far as I can see, it's working just fine with the provided examples : https://github.com/melonjs/melonJS/blob/master/examples/shapes/js/entities/entities.js#L21 and it matches the documentation : http://melonjs.github.io/melonJS/docs/me.input.html#registerPointerEvent what is "not working" on your side ? Quote Link to comment Share on other sites More sharing options...
Hashasm Posted January 10, 2017 Author Share Posted January 10, 2017 onActivateEvent: function () { //register on mouse/touch event me.input.registerPointerEvent("pointerdown", this, this.onSelect.bind(this)); }, Note:-"i am working on isomatric tiled map where i am building game like sim city " its throwing error: TypeError: this.onSelect is undefined[Learn More] request :- "Please can any one can suggest me one good tutorial which has all pointer functions,HUD for clone-and-drag menu ,zooming functions " Thanks in advance Quote Link to comment Share on other sites More sharing options...
Parasyte Posted January 10, 2017 Share Posted January 10, 2017 We will probably need to see the full class definition you created. The error console is telling you that you don't have an onSelect method on the class. Your original snippet is practical; the method you are binding exists. But you did not describe any errors for that code. Quote Link to comment Share on other sites More sharing options...
Hashasm Posted January 10, 2017 Author Share Posted January 10, 2017 game.PlayerEntity = me.Entity.extend({ /** * constructor */ init:function (x, y, settings) { .....some code is here for player }, here i am registring now no errors but on pointerdown nothing is showing // onActivate function onActivateEvent: function () { // register on the 'pointerdown' event me.input.registerPointerEvent('pointerdown', this, this.pointerDown.bind(this)); }, // pointerDown event callback pointerDown: function (event) { if (me.levelDirector.getCurrentLevelId()) { var layer = me.game.world.getChildByName("bottom")[0]; var tile = layer.getTile(event.gameWorldX, event.gameWorldY); if (tile) { console.log( tile.col + "," + tile.row) } else{ console.log("not a tile"); } } return false; }, /** * update the entity */ update : function (dt) { .....code for key board functions }, /** * colision handler * (called when colliding with other objects) */ onCollision : function (response, other) { // Make all other objects solid return true; } }); Quote Link to comment Share on other sites More sharing options...
Hashasm Posted January 10, 2017 Author Share Posted January 10, 2017 Thank you taking time to solve my problems we creating a game like sim city I would be needing your help guys ...thank you so much for replying me. i found melon is good to start with my game carrier Quote Link to comment Share on other sites More sharing options...
obiot Posted January 10, 2017 Share Posted January 10, 2017 probably because me.levelDirector.getCurrentLevelId() returns 0, which is I guess the first index value. why do you actually have that test ? Quote Link to comment Share on other sites More sharing options...
Hashasm Posted January 10, 2017 Author Share Posted January 10, 2017 i am trying to get position of each tile me.levelDirector.getCurrentLevelId() it wont return 0; beacuse:- // onActivate function onActivateEvent: function () { // register on the 'pointerdown' event me.input.registerPointerEvent('pointerdown', this, this.pointerDown.bind(this)); }, // pointerDown event callback pointerDown: function (event) { console.log("hai"); return true; }, now i am just consoling hai still not working.. Quote Link to comment Share on other sites More sharing options...
Hashasm Posted January 10, 2017 Author Share Posted January 10, 2017 @obiot the link which u give me https://github.com/melonjs/melonJS/blob/master/examples/shapes/js/entities/entities.js#L21 in this repository it dont have any melonjs.js file and its not working if i add my melonjs 4. Quote Link to comment Share on other sites More sharing options...
obiot Posted January 10, 2017 Share Posted January 10, 2017 the latest build for master is here : http://melonjs-builds.s3.amazonaws.com/index.html?prefix=artifacts/master/1920/build/ Quote Link to comment Share on other sites More sharing options...
Hashasm Posted January 10, 2017 Author Share Posted January 10, 2017 @obiot shapes eample is working after updating js file. but i am not getting the pointer position .....by using that syntax from documentation. hey now i fiund some solution but totally different syntax can anyone explain me this this is the code me.input.registerPointerEvent("pointerdown", me.game.viewport, function (event) { me.event.publish("pointerdown", [ event ]); },false); .... this.pointerDown = me.event.subscribe("pointerdown", function (event) { if (me.levelDirector.getCurrentLevelId()) { var layer = me.game.world.getChildByName("bottom")[0]; var tile = layer.getTile(event.gameWorldX, event.gameWorldY); if (tile) { console.log( tile.col + "," + tile.row) } else{ console.log("not a tile"); } } }); its working fine now i Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.