Search the Community

Showing results for tags 'Objects'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Platform
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 32 results

  1. Hi all. How to scale all(tiles, sprites ect...) except canvas, for game with the width and height of 100% on all devices? game.scale.scaleMode = Phaser.ScaleManager.USER_SCALE;if(game.width < 667){game.scale.setUserScale(0.5,0.5) }
  2. or phrased differently.. how do i get my polygons (created on an object layer in tiled) to appear in my phaser game world ? thx!
  3. Hello, want to apologize in advance for my English (I use GoogleTranslate). I ask this question about the collision objects. I could not find how to work with the methods collideAgainst, collisionGroup, setCollideAgainst, setCollisionGroup. How can I customize the behavior of the object depending on which object he encountered. Thanks in advance.
  4. Sword = function (x, y) { this.sprite = game.add.sprite(x, y, 'sword'); this.sprite.anchor.setTo(0.5, 0.5); this.sprite.immovable = true; this.sprite.body.velocity.y = -150; this.sprite.outOfBoundskill = true;};Mummy = function (x, y) { this.sprite = game.add.sprite(x, y, 'mummy'); this.sprite.anchor.setTo(0.5, 0.5); this.sprite.immovable = true; this.sprite.body.velocity.y = 30; this.sprite.animations.add('walk');'walk', 7, true);}var swords = [];var mummies = [];function preload(){ game.load.spritesheet('player', 'assets/player.png', 64, 22); game.load.spritesheet('mummy', 'assets/mummy.png', 64, 22); game.load.image('sword', 'assets/sword.png');}function create(){ game.stage.backgroundColor = '#E2DBCE'; player = game.add.sprite(10,530, 'player'); = 'player'; player.anchor.setTo(0.5, 0.5); player.body.collideWorldBounds = true; player.body.immovable = true; player.animations.add('walk'); leftKey = game.input.keyboard.addKey(Phaser.Keyboard.LEFT); rightKey = game.input.keyboard.addKey(Phaser.Keyboard.RIGHT); spaceKey = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);}function update() { game.physics.collide(swords, mummies, swordHitMummy. null, this); if (spaceKey.isDown) { createSword(player.x, player.y-50); } for (var i=0; i<10; i++){ createMummy(Math.random(), Math.random()); } }function createSword (x, y) { swords.push(new Sword(x, y));}function createMummy (x, y) { mummies.push(new Mummy(x, y));}function swordHitMummy (sword, mummy) { console.log("success");}The design of my game is that the player moves left and right firing swords (which move only up) at mummies (which move only down). The player is at the bottom of the canvas and the swords are created at the bottom and moved up, the mummies spawn in randomly at the top and move down. The code above had been edited and had pieces removed as to focus just on my current issue. I am unsure of how to collide the mummies and swords as they are stored in arrays. I tried a few ideas earlier but could not get it to work properly, so decided to post on here in order to find the best way to achieve this. I tried using groups, but it appeared that I could only store sprites in groups and not objects - although I could be wrong, I am quite new to this! I also tried looping through the arrays and colliding individual objects, but I had problems with objects with no sprite attached still colliding and causing errors. Basically I want to know what would be the best possible way to do this, am I even doing this at all right? Should I be using arrays (I noticed they were used in the tank example)? Please consider that I am quite new to programming and phaser. Thanks.
  5. Hey guys, I need to know how I automatically spawn multiple objects, example in a shooting game, where the weapon should fire every time the user clicks.
  6. Hey all, I'm fairly new to object-oriented javascript and had a quick question about the "right" way to set up an object. Namely, what's the benefit of using prototype versus just creating the function inside the object? Below are some examples: Using prototype function Rectangle(left, top, right, bottom){ this.left = left; = top; this.right = right; this.bottom = bottom; this.width = right - left; this.height = bottom - top;} Rectangle.prototype.getArea = function () { return this.width * this.height; } Not using prototype function Rectangle(left, top, right, bottom){ this.left = left; = top; this.right = right; this.bottom = bottom; this.width = right - left; this.height = bottom - top; this.getArea = function() { return this.width * this.height; }}As far as usage goes, I don't really see a difference, but I was curious if there was something I'm missing. Any info or advice is appreciated. Thanks!
  7. Hi, I'm fairly new to game programming using HTML5. Although saying that I have been using Javascript for many years and will continue to do so for years to come. Basically I have made a couple of very basic games up to now just practising in general for when I decide to consider making a more serious attempt at a game for people to play. I noticed while learning some of the basics that there was quite a lot of code that I had to rewrite almost exactly the same for all the basic games I made, so I figured "Why not make a file that I can reuse for almost all games I intend to make?". Well I begun doing so and soon ran into a few "scope" problems, I figured out a way around them but then after reading a few threads on these forums when I first landed here yesterday, I am afraid that my style of OOP (So to speak) with Javascript is not the best way to go about things. I was just looking for pointers in regards to where this file can be improved due to not programming the way accepted by most Javascript developers? function Canvas(canvasID){ this.canvasID = canvasID; this.canvasDOM = document.getElementById(this.canvasID); this.ctx = this.canvasDOM.getContext('2d'); this.width = this.canvasDOM.width; this.height = this.canvasDOM.height; this.clear = function(){ this.ctx.clearRect(0, 0, this.width, this.height); }; this.fill = function(color){ this.ctx.fillStyle = color; this.ctx.fillRect(0, 0, this.width, this.height); };}var engine = new function(){ this.running = false; this.animator = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame; this.start = function(){ this.running = true; this.tick(); }; this.stop = function(){ this.running = false; }; this.tick = function(){ if(!this.running) return; update(); render();, function(){ engine.tick(); }); };} Now there are a few things I am sure are terribly wrong, the most prominent being in the tick method of the engine instance where I call itself by using "engine.tick()" . This is where, as I mentioned before, I had "scope" issues. Any advice regarding how I should change that would be much appreciated. Now the way in which I currently (And intend to continue if possible) using this file for my games is like so - var canvas = new Canvas("gameCanvas");engine.start();function update(){ canvas.clear(); //update game}function render(){ //render game} I hope you manage to decipher what I mean by this and understand my programming. Thanks in advance, Chuxx.