Search the Community

Showing results for tags 'selection'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser
    • Pixi.js
    • Babylon.js
    • Panda.js
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 4 results

  1. Hi all, I have two sprites ( sprite A and sprite B ) that I want to select and move around the screen one at the time, like this: click on sprite A to select it, sprite B should be then deselcted click anywhere in the world to move sprite A to where the mouse clicked double click on a sprite A to cast spell 1 double click on sprite B to cast spell 2 Issues I have are: Issue: If sprite A is already selected, and I single click on sprite B to select it, then sprite A moves to location of sprite B. Intended: no sprite moves, sprite B is selected and sprite A is deselected Issue: If a sprite is already selected, and I single click on it, the sprite is deselected (and the other is selected). Intended: the sprite remains selected Issue: Double clicking on the world (outside any sprite) cause a selected sprite to move two steps towards where clicked. Intended: Double clicking on the world should be ignored Issue: Single clicking anywhere but the center of a selected sprite makes it move a bit towards where clicked. Intended: single clicking on a selected sprite should be ignored Issue: The two sprite overlap. Intended: collision and separation What I'm doing wrong Thanks! Code var playState = { create: function() { this.mouseClicks = 0; this.mouseClicksStarted = false; this.createPlayers(); this.myEvent = game.input.onDown.add(this.movePlayer, this); this.playerGroup.forEach(function(player) {,this); //param 1: sprite, param2: pointer }, this); }, update: function() { game.physics.arcade.collide(this.playerGroup); }, countClicks: function(player, pointer) { this.mouseClicks ++; this.player.canMove = false; if (this.mouseClicksStarted) { return; } this.mouseClicksStarted = true; //call function after x seconds setTimeout(function() { if(this.mouseClicks > 1) { if(player.role == "thrower") { console.log("double: casting thrower spell") } else { console.log("double: casting catcher spell") } //One click } else { this.selectPlayer(player); } this.mouseClicksStarted = false; this.mouseClicks = 0; }.bind(this), 250); }, selectPlayer: function(player) { this.playerGroup.forEach(function(player) { if(player.isSelected) { player.isSelected = false; player.tint = 0xffffff; } else { player.isSelected = true; player.tint = 0xff0000; } }, this); }, createPlayers: function() { this.playerGroup =; this.player = new Player(, 'player', 'thrower', true);; this.playerGroup.add(this.player); this.player.reset(,; this.player2 = new Player(, 'catcher', 'catcher', false);; this.playerGroup.add(this.player2); this.player2.reset(,; }, movePlayer: function (pointer) { this.playerGroup.forEach(function(player) { if(player.isSelected) { if (this.tween && this.tween.isRunning) { this.tween.stop(); } var duration = (game.physics.arcade.distanceToPointer(player, pointer) / 400) * 1000; this.tween = game.add.tween(player).to({ x: pointer.x, y: pointer.y }, duration, "Sine.easeInOut", true); game.add.tween(player.scale).to({x: 1, y: .8}, duration).to({x: 1, y: 1}, 1000, Phaser.Easing.Elastic.Out).start(); player.rotation = game.physics.arcade.angleToPointer(player); } }, this); }, }; Player var Player = function (game, sprite, role, isSelected) { //save passed variables so they can be accessed later this.role = role; this.isSelected = isSelected; this.max_energy = 100; this.currentEnergyLevel = 0;, game, game.width/2, game.height-150, sprite); this.anchor.setTo(0.5, 0.5); this.scale.setTo(1); game.physics.enable(this, Phaser.Physics.ARCADE); this.body.collideWorldBounds = true; this.body.bounce.setTo(0.9, 0.9); //this.body.immovable = true; this.playerKillParticles = game.add.emitter(0,0,15); this.playerKillParticles.makeParticles('playerParticle', 2); this.playerKillParticles.setYSpeed(-100,0); this.playerKillParticles.setXSpeed(-100,100); this.inputEnabled = true; this.input.useHandCursor = true; //this.input.priorityID = 1; }; Player.prototype = Object.create(Phaser.Sprite.prototype); Player.prototype.constructor = Player; Player.prototype.setRole = function(role) { this.role = role; }; Thanks!
  2. I need a way to allow the user to select a colour by clicking on a certain point of a wheel. The colour wheel that I am using looks like this (Sorry for huge image) : I would like a way for the user to be able to click somewhere on the wheel, and for phaser to be able to get the hex value of that point. I know that this can be done with canvas but my game uses webGL as well so I need the solution to work with both of possible. Thanks for any help
  3. When creating a box, there's the assumption that all sides are of equal length. However, for a rubberband selection in an RTS I'd like to create a rectangular box on the fly (from the screen down to the ground) and then check intersections with all units on the screen to select them. How could I create a rectangular box, or is there even a better way to do rubberband selection in BabylonJS?
  4. I use Graphicsgale for creating pixel art. It has many cool features, but that one, that is missing for me, is object selection. Everyone, who have used flash, will understand - after drawing a simple object, like ball or more complex character, after conveting it to symbol or movieclip, whenever you click at this image, you can drag and edit it, cause it's properties are saved in memory. Is it possible to save object like this in graphicsgale or another bitmap graphics tool(free, paid)? Cause it takes much time to select area of object each time, when working with 2 or more on the scene. I'm looking for something like quick selection tool, but better are saved objects - for bitmap graphics!