• Content count

  • Joined

  • Last visited

  1. okie.. for toggle of hud element(munu) can i use addChild and removeChild methods.
  2. yeah thanks for the links i already surf through wiki pages but i didt find newer version method like // Old Code -> New Code me.game.remove -> me.game.world.removeChild me.game.add -> me.game.world.addChild me.game.collide -> me.game.world.collide me.game.getEntityByProp -> me.game.world.getChildByProp me.save.delete -> to me.save.remove me.entityPool.newInstanceOf -> me.pool.pull me.entityPool.add -> me.pool.register me.Rect.set -> me.Rect.setShape me.Font.set -> me.Font.setFont this so i struck . thanks
  3. but here i am using GUi_object i am trying to give for gui_object directly To give opatcity we can set opacity like this.setOpacity(0.5) is their any property in which we can give background color like this.bgcolor("white") or this.background_color("white") (just asking if their any properties like this) game.HUD.menu2 = me.GUI_Object.extend({ init: function (x, y) { var settings = {} settings.image = "Untitled-1-01"; settings.framewidth = 300; settings.frameheight = 74; // super constructor // me.game.world.addChild(camera, 10); this._super(me.GUI_Object, "init", [x, y, settings]); // create a standalone sprite, with anchor in the center // define the object z order this.pos.z = 4; this.setOpacity(0.5); this.anchorPoint.set(0, 0); this.isHoldable = true; // status flags this.selected = false; this.hover = false; // me.game.viewport.follow(this.pos, me.game.viewport.AXIS.BOTH); //me.game.viewport.shake(10, 500, me.game.viewport.AXIS.BOTH); // to memorize where we grab the shape this.grabOffset = new me.Vector2d(0, 0); }, /** * function called when the pointer is over the object */ onOver: function (event) { this.setOpacity(1.0); //console.log(this) //console.log(me.game.world.getChildByGUID("4349545931-16")) menu1,menu2,menu3,menu4=""; // // me.game.viewport.fadeIn("#FFFFFF",100, function () { // me.game.world.removeChild(mybutton,true); // }); }, /** * function called when the pointer is leaving the object area */ onOut: function ( /* event */ ) { this.setOpacity(0.5); // me.game.world.addChild(mybutton) // me.game.viewport.fadeOut("#FFFFFF", 100, function () { // me.game.world.addChild(mybutton); // }); console.log(menu1) if(menu1 !=undefined){ // me.game.viewport.fadeIn("#FFFFFF",100, function () { // me.game.world.removeChild(mybutton,true); me.game.world.removeChild(menu1); me.game.world.removeChild(menu2); me.game.world.removeChild(menu3); //me.game.world.removeChild(menu4); // }); // menu1,menu2,menu3,menu4=null; } else{ console.log(menu1) menu1,menu2,menu3,menu4=null; } // console.log(menu1) }, // output something in the console // when the object is clicked onClick: function (event) { console.log("clicked!"); if(menu1 == undefined){ menu1= me.game.world.addChild(new game.HUD.menu3(70, 70)); menu2=me.game.world.addChild(new game.HUD.menu4(140, 70)); menu3=me.game.world.addChild(new game.HUD.menu5(200, 70)); // menu4=me.game.world.addChild(new game.HUD.menu6(260, 70)); } else{ console.log("already have a child"); } path=[]; me.input.registerPointerEvent("pointerdown", me.game.viewport, function (event) { me.event.publish("pointerdown", [event]); }, false); // me.collision.check(); var camera = new me.Sprite(500, 500, { image: "building_64_64-02", spritewidth: 30, spriteheight: 30, }); me.game.world.addChild(new me.Entity(500, 500, { width : 30, height : 30, type : me.collision.types.WORLD_SHAPE, })); me.game.world.addChild(camera, 10); camera.animationpause = true; camera.addAnimation("stand", [1]); camera.setCurrentAnimation("stand"); setTimeout(function () { me.game.world.removeChild(camera); }, 10000); // camera.flicker(1000, function () { // me.game.world.removeChild(camera); //}); if (this.hover === true) { this.grabOffset.set(event.gameX, event.gameY); this.grabOffset.sub(this.pos); this.selected = true; // don"t propagate the event furthermore return false; } var tile = this.refLayer.getTile(event.gameWorldX, event.gameWorldY); console.log(tile); // me.game.world.addChild(new mycopy(10, 15)); // me.game.world.addChild(new MySprite()); // don't propagate the event return false; }, onRelease: function (event) { console.log("onRelease!"); this.selected = false; }, onHold: function (event) { console.log("holding mouse"); // don't propagate the event me.input.registerPointerEvent("pointermove", this, this.pointerMove.bind(this)); // this.handler = me.event.subscribe(me.event.POINTERMOVE, this.pointerMove.bind(this)); // return false; }, pointerMove: function (event) { //console.log(this.getBounds().containsPoint(event.gameX, event.gameY)); // me.game.viewport.follow(this.pos, me.game.viewport.AXIS.BOTH); this.hover = this.getBounds().containsPoint(event.gameX, event.gameY); console.log(this.hover); // move event is global (relative to the viewport) /* if (this.getBounds().containsPoint(event.gameX, event.gameY)) { // calculate the final coordinates var parentPos = this.ancestor.getBounds().pos; var x = event.gameX - this.pos.x - parentPos.x; var y = event.gameY - this.pos.y - parentPos.y; }*/ if (this.selected) { // follow the pointer // me.game.world.moveUp(this); this.pos.set(event.gameX, event.gameY, this.pos.z); this.pos.sub(this.grabOffset); } if (this.hover || this.selected) { return false; } }, });
  4. hi guys someone please help me to upgrade this file to newer version of melon js.. inventory.js
  5. Hi, can anyone help to set the background for HUD objects
  6. hmm thank you , saving in local storage i got one example but I dont know how to start with option 2,how can i change my tmx /json directly suggest me some documentation or example to do the same Thank you
  7. finally i got it. i am creating entity with collision type . but can you guys help me with this:- now i am creating one new building in my game, when i am refreshing my browser that building disappearing i mean its not saving can someone tell me how to save my building at that position only even when I refresh my building
  8. HI guys , finally i found the solution. i just created a pointer down function on click of the particular entity i am removing it.
  9. I was creating sprite and i am creating collision entity at the same position of the sprite ,now i am having confusion how to pass the shapes i mean to which entity it will take shape.
  10. 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
  11. I am still trying but no luck please can someone help me on this
  12. 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.
  13. 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
  14. 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
  15. 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