tdnshah

Members
  • Content count

    3
  • Joined

  • Last visited

  1. How to use fontsquirrel with Phaser

    @Jeff Daze Thanks for that great explanation but my game is going to be played in offline mode hence the google apis for fonts wont work i our case so can u you please help me with embedding a ttf or any other way to embed custom fonts file in phaser
  2. Phaser PopUp Using Modal.js

    I want to add popup to the game i am developing using Phaser.js. After searching a bit for the same i could found modal.js for this. I am trying to integrate modal.js but am unable to get through. And I am getting an error "Uncaught TypeError: Cannot set property 'modal1' of undefined" below is the part of my code which i am using to add the modals to my game. If any one can help me with this error please will be a great help. Here is my code var reg={}; createModals: function(){ reg.modal.createModal({ type: "modal1", includeBackground: true, modalCloseOnInput: true, itemsArr: [{ type: "graphics", graphicColor: "0xffffff", graphicWidth: 300, graphicHeight: 300, graphicRadius: 40 }, { type: "text", content: "The white behind me\nis a [Phaser.Graphic]", fontFamily: "Luckiest Guy", fontSize: 22, color: "0x1e1e1e", offsetY: -50 }, ] }); }, showModal1: function(){ reg.modal.showModal("modal1"); }
  3. i am making a game using phaser and i want to make unlimited no of tiles can think like stacked tiles. When the user drags the topmost tile and places it in the drop area, the same tile below it should appear and should be draggable. My present code:- ` var greenTile = this.add.sprite(250,500,'greenTile'); greenTile.inputEnabled=true; greenTile.input.enableDrag(); greenTile.events.onDragStart.add(onDragStart, this); greenTile.events.onDragStop.add(onDragStop, this);` the total code is of my game state is :- ` var patternsRatio = patternsRatio || {}; var x = 50; var y = 100; var canvas; var canvasBG; var canvasGrid; var canvasSprite; var canvasZoom = 32; var spriteWidth = 8; var spriteHeight = 8; patternsRatio.game1 = function () {}; patternsRatio.game1.prototype = { preload: function () { this.load.image('greenTile','assets/images/greentile.png') this.load.image('redTile','assets/images/redtile.png') }, create: function () { this.game.stage.setBackgroundColor(0x2d2d2d); var question_l1 = "Puzzle 1: Enlarge this pattern by a factor of 2." var style_l1 = {font: "25px Comic Sans MS Bold", fill: "#fff", align:"center"}; var quet_l1=this.game.add.text(this.game.world.centerX,this.game.height-600, question_l1, style_l1) quet_l1.anchor.setTo(0.5) this.placetiles() var greenTile = this.add.sprite(250,500,'greenTile'); greenTile.inputEnabled=true; greenTile.input.enableDrag(); greenTile.events.onDragStart.add(onDragStart, this); greenTile.events.onDragStop.add(onDragStop, this); var redTile = this.add.sprite(100,500,'redTile'); redTile.inputEnabled=true; redTile.input.enableDrag(); redTile.events.onDragStart.add(onDragStart, this); redTile.events.onDragStop.add(onDragStop, this); }, update: function () { }, placetiles: function () { this.game.create.grid('drawingGrid', 16 * canvasZoom, 16 * canvasZoom, canvasZoom, canvasZoom, 'rgba(0,191,243,0.8)'); canvas = this.game.make.bitmapData(spriteWidth * canvasZoom, spriteHeight * canvasZoom); canvasBG = this.game.make.bitmapData(canvas.width + 2, canvas.height + 2); canvasBG.rect(0, 0, canvasBG.width, canvasBG.height, '#fff'); canvasBG.rect(1, 1, canvasBG.width - 2, canvasBG.height - 2, '#3f5c67'); var x = 80; var y = 64; canvasBG.addToWorld(x, y); canvasSprite = canvas.addToWorld( x + 1, y + 1); canvasZoom,canvasZoom canvasGrid = this.game.add.sprite(x + 1, y + 1, 'drawingGrid'); canvasGrid.crop(new Phaser.Rectangle(0, 0, spriteWidth * canvasZoom, spriteHeight * canvasZoom)); } }; ` I am also facing problem when i am adding a input.enable code below the "greenTile" variable then the redTile vanishes of can any tell why this happens.