• Content count

  • Joined

  • Last visited

  1. thank you for responding. actually i am crating a new entity and making as its type =collision around my sprite image. but the problem is when i drag my sprite image the collision entity which i have crated it wont follw my sprite can you please help me with it here is my code.... game.mycopy = me.DraggableEntity.extend({ init: function (x, y, settings) { // console.log("Dragged !!!!!!!!!!!!!!!!!!!!!!!!"); this._super(me.DraggableEntity, "init", [x, y, settings]); this.xcor = x; this.ycor = y; this.anchorPoint.set(0.5, 0.5); this.isHoldable = true; this.hover = true; this.entityselected = true; var settle = {}; this.settle = settings; // console.log("settings" + JSON.stringify(settings)); }, update: function () { // this.body.update(dt); // this.body.vel.set(0,0); return true; }, dragStart: function (event) { var temp; if (this.entityselected === true) { this._super(me.DraggableEntity, "dragStart", [event]); console.log("drag dragstart"); this.isHoldable = true; this.hover = true; this.entityselected = true; // me.game.world.removeChild(temp); // console.log(this.temp) // } //return false; }, dragMove: function (event) { if (this.entityselected === true) { this.isHoldable = true; this.hover = true; this.entityselected = true; this._super(me.DraggableEntity, "dragMove", [event]); // console.log(me.input.pointer.pos.x); //console.log(me.input.pointer.pos.y); me.collision.check(this); } //return false; }, dragEnd: function (event) { var x,y; // console.log(temp); // var collide=new Object(); if (this.entityselected === true) { if (me.levelDirector.getCurrentLevelId()) { var layer = me.game.world.getChildByName("background")[0]; var tile = layer.getTile(event.gameX, event.gameY); if (tile) { if (me.collision.check(this) === false) { this._super(me.DraggableEntity, "dragEnd", [event]); console.log("drag end"); console.info(tile.tileId); x = this.pos.x; y = this.pos.y; console.log("tile.col" + tile.col); console.log("tile.row" + tile.row); me.game.world.removeChild(this); this.isHoldable = false; this.hover = false; this.entityselected = false; //var viewport = me.game.viewport; // console.log("viewport"+JSON.stringify(viewport)); // me.game.viewport.follow(this, me.game.viewport.AXIS.BOTH); // this.hover = false; //this.entityselected = false; me.game.world.addChild(new MySprite(tile.row, tile.col, x, y, { image: this.settle.image, framewidth: this.settle.width, frameheight: this.settle.height, })); //my collision entity temp= me.game.world.addChild(new me.Entity(this.pos.x,this.pos.y, { image: this.settle.image, width: 64, height: 64, type: me.collision.types.WORLD_SHAPE, })); /* console.log(temp); me.game.world.addChild(new game.mycopy(this.pos.x,this.pos.y, { image: this.settle.image, height: 64, width: 64, type: me.collision.types.WORLD_SHAPE })); */ } } } } me.collision.check(this); }, onCollision: function ( /*response, other*/ ) { // Make all other objects solid console.log("coliding..............") return true; } }); so each and every time when i drop i am trying to remove my collision entity and creating new collision entity for my sprite for its new position , but When i am removing collision entity it will remove all collision entities which i have crated for other sprites also.. Please help me with this
  2. I am still trying but no luck please can someone help me on this
  3. I am creating city building game in that from hud element I am dragging and placing my house in a map,so user experience perspective if he tries to put a house over an exsisting house then i should say u can't place here(check for overlap or collision), so only I want to prevent being collide with each other. after dropping the house I am letting user to modify the house place i mean again in the game also use can drag his house anywhere he wants. so please can you tell me how can I do the same.
  4. HI ALL, I am new to kiwi i am looking for frame work which has all functionalities to build game like simcity or township like game which allows user to create their own city drag and drop the house crating of roads modification etc Please help me can i able to build my game with phaser. and ofcourse support for:- multiplayer, tiled map editor maps, storing data , updating json etc
  5. HI ALL, I am new to kiwi i am looking for frame work which has all functionalities to build game like simcity or township like game which allows user to create their own city drag and drop the house crating of roads modification etc Please help me can i able to build my game with KIWI
  6. HI , can someone tell me how can I detect collision between two me.DraggableEntity entites. or detecting collision between two sprites when they are dragging and dropping on each other. we can detect the collision by using me.DroptargetEntity but when i make an entity as me.DroptargetEntity then i cant able to drag the same please help me with this Thank You
  7. hi thanks for the timely response, Here i am trying my level best to get that functionality in the code. If you can share some code reference it will be of a great help. Or please guide a good way to start implementing it.
  8. hmm yeah I am getting the collision by using collision object. but my requirement is like, In my case i want a sprite image which is collidable in the map, And at the same time i want to drag and drop the sprite image. in my game i have HUD element that i can drag and clone and create now sprite image .when i drop that image i want to make that image as Collidable.. like wise i am creating or modifying my map inside the game in that i am building roads so i wana make those roads as Collidable dynamically.Is there any other workaround for this kind of issue ???
  9. HI all, Insted of using collision object to define collision i am using tiled map collision editor to mention the collision to the tile(as shown in collision.pgn) but its not working my player(here my player is the building) going through that tile(as shown in building.png) can some one tell me where i am doing it wrong. still its passing my collision tile.... . here is my code update : function (dt) { .... ..... ..... me.collision.check(this); ....... ..... ...... }, onCollision: function ( response) { // Make the object solid return true; }
  10. If I have the Path array already defined ,how can i move sprite through the particular path repeatedly. like this https://github.com/Kibo/melonjs-cookbook/tree/master/cookbook/patrol in my isomatric map. when i am trying to reuse the functions its throwing error because the melonjs version which they have used in this example is version 0.9.9. BUT i am using 4.1.0 can any one help me on this..
  11. thank you bro i understood
  12. HI all, its going well with melon js.. I am modifying my tiled map dynamically i mean in game i am creating roads and its happening . now i wanted to have a car on that particular road and it should move road from starting to end again from end of the road to starting of the road.. And when I restart my game my modifications should come .Can any one help me how can i update my game map and its animations. Thank You.
  13. yesss i got it thanks @Parasyte.. i tried me.viewport.fadeIn(..) but i was getting error as "TypeError: me.viewport is undefined". in documentation i didt get how to use or how to give me.game.viewport.fadeIn() insted of me.viewport.fadeIn(..). I think i am not able to understand the document properly. can you Please suggest me some tips how can i improve myself in better understanding of MelonJS document
  14. i dont have any object but i specified object layer and on clicking on that layer i am loading new map. as shown below image. by using object layer name(map1) i am writing the function as shown below game.redirect = me.Entity.extend({ init: function (x, y, settings) { ..... ....... ....... // set the display to follow our position on both axis // me.game.viewport.follow(this.pos, me.game.viewport.AXIS.BOTH); // ensure the player is updated even when outside of the viewport //this.alwaysUpdate = true; // the main player spritesheet }, onActivateEvent: function () { //register on mouse/touch event me.input.registerPointerEvent("pointerdown", this, this.onSelect.bind(this)); }, // mouse down function onSelect: function (event) { console.log("haiiiiiiii"); // console.log(me.TMXObjectGroup(this)); // me.state.transition("fade", "#FFFFFF", 250); //fade not workin me.levelDirector.loadLevel("temp"); //changing state } }); now map will change but sometime browser screen get blak or map wont change until i press some key from keyboard ,then it will come. Note : some time map will load and appear correctly ..sometimes i wont come untill i press a key
  15. how about using me.LevelEntity for click event. and about idle animations I dont have player in my game its kind of simcity game.