Search the Community

Showing results for tags 'overlap'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

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

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 106 results

  1. I have this code: scene.physics.add.overlap(spears.children.entries[numberOfSpearThrowerMachines], platforms, stopSpear, null, this); function stopSpear(number) { spears.children.entries[number].setVelocityX(0); } I am trying to send a parameter to the function stopSpear when calling it. Like this: scene.physics.add.overlap(spears.children.entries[numberOfSpearThrowerMachines], platforms, stopSpear(numberOfSpearThrowerMachines), null, this); but this does not work obviously, so how do I do it instead?
  2. I have an endless runner with flies that are enemies flying towards the player. The player jumps into the air and onto the top of the fly to kill it. I would like to enable gravity on the fly on overlap so that it falls to the ground when it dies. However, my problem is that when the fly falls sometimes it overlaps with the player sprite on decent causing the overlapCallback function (killFlies) to be called more than once. How can I have an enemy sprite like this die and adhere to gravity yet not have the overlapCallback function triggered again when it's falling? Any ideas? Is there any way to disable overlap once the overlap occurs? Setting fly.body.enable = false won't work as I then can't set velocity or gravity on the fly sprite when it dies. Please see my overlapCallback function below. Any suggestions would be much appreciated (am new to Phaser). killFlies: function(player, fly){ if (player.body.touching.down) { this.bounce(); //fly.body.enable = false; fly.body.allowGravity = true; this.stompSound.play(); fly.animations.play('die').onComplete.addOnce(function () { fly.kill(); }, this); }else { this.gameOver(); } fly.body.touching = fly.body.wasTouching; },
  3. A collider collides only with set tiles on a tilemap. However, if you are using an overlap with a tilemap, it always callbacks. If you log the index of the Tile, it's 0. So "no set tile". Is that intended behavior?
  4. See updates in below comments I made a collider: this normally works. But however this time it doesn't. There is a collider which lets the player colliding with (this) object. when I move the player on the object, the collideCB is triggered. But there is no collision. Even in debug mode for arcade physics, I can see the body. But they are not colliding, just overlapping. Anyone has an idea why? body: this.scene.physics.world.enable(this); this.setOrigin(0, 0); this.body.setSize(8, 8, false); this.body.setImmovable(true); this.body.allowGravity = false; colliding code: this.scene.physics.add.collider(this.scene.config.player, this, collideCB, () => { return this.getData('active'); }, this) (...) collideCB() { console.log('working') } Also, the debug information seems to clearly address both sprites, that should collide. but it does not collide and the callback is fired. ALl other collisions are working. (attached screenshot)
  5. Hello, If I have a tilemap with a dynamic layer, a player with collisions enabled with this layer - how do I manually check whether the player is overlapping specific tile? I try this way: scene.physics.world.enable(player); scene.physics.add.collider(player, layer); ... var tile = layer.getTileAtWorldXY(Xpos, Ypos, true); console.log(scene.physics.world.overlap(player, tile)); .. but I always get False printed, even if selected tile is right behind the player. Same result with calling collide(), same result if tile's index is -1 or something else. What am I missing?
  6. jd.joshuadavison

    Overlap ignores scroll factor

    I'm using a callback function on the overlap method, but it's firing at the wrong time. After a bit of calculation/trial and error I worked out that it is firing where the sprite would have been if the scrollFactor of the sprite was the default setting of 1. I assume this is a bug? See demo on jsFiddle. Update: it also ignores the objects origin and assumes its origin is the default 0.5. I've updated the demo. Update 2: I'm now fairly certain this is not expected behaviour, so I've raised an issue on GitHub. Thanks, Josh
  7. Hi, I hope that I find you well, I am a little stuck. I have a group of sprites, that on overlap of another jump sprite image, I require it to play the jump animation, but only on the individual sprite within the group, when it has overlapped. My code, is pretty much working how I want apart from this issue, in the current build, on overlap the animation will play for all sprites within the group (not an individual basis), and will trigger again (beyond the original, overlap) if another sprite hits the jump image. Appreciate any assistance. var game; var globalParams = { calculatedWidth: 1350, calculatedHeight: 900 } var GameResolution = { _1350: 1350, _960: 960 }; function calculateSize() { // Get Pixel Width and Height of the available space var w_w = window.innerWidth * window.devicePixelRatio; var w_h = window.innerHeight * window.devicePixelRatio; var g_w = w_w; // We prepared all assets according to aspect ratio of 1.5 // Since we are going to use different assets for different resolutions, we are not looking at the resolution here var originalAspectRatio = 1.5; // Get the actual device aspect ratio var currentAspectRatio = g_w / w_h; if (currentAspectRatio > originalAspectRatio) { // If actual aspect ratio is greater than the game aspect ratio, then we have horizontal padding // In order to get the correct resolution of the asset we need to look at the height here // We planned for 1350x900 and 960x640 so if height is greater than 640 we pick higher resolution else lower resolution if(w_h > 640){ globalParams.selectedResolution = GameResolution._1350; globalParams.calculatedHeight = 900; globalParams.calculatedWidth = w_w * (900 / w_h); } else { globalParams.selectedResolution = GameResolution._960; globalParams.calculatedHeight = 640; globalParams.calculatedWidth = w_w * (640 / w_h); } } else { // If actual aspect ratio is less than the game aspect ratio, then we have vertical padding // In order to get the correct resolution of the asset we need to look at the width here if(w_w > 960){ globalParams.selectedResolution = GameResolution._1350; globalParams.calculatedWidth = 1350; globalParams.calculatedHeight = w_h * (1350 / w_w); } else { globalParams.selectedResolution = GameResolution._960; globalParams.calculatedWidth = 960; globalParams.calculatedHeight = w_h * (960 / w_w); } } } window.onload = function () { calculateSize(); game = new Phaser.Game(globalParams.calculatedWidth, globalParams.calculatedHeight, Phaser.AUTO, 'gameDiv'); game.state.add('main', mainState); game.state.start('main'); //game.forceSingleUpdate = true; } var yourGroup; var mainState = { preload: function() { if(!game.device.desktop) { game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; game.scale.setMinMax(game.width/2, game.height/2, game.width, game.height); } game.scale.pageAlignHorizontally = true; game.scale.pageAlignVertically = true; // Background game.stage.backgroundColor = '#71c5cf'; // Horse Sprites for (var i = 1; i <= 3; i++) { this.load.spritesheet('runner'+i, 'assets/horse-'+i+'.png', 368, 300); } // Other Sprites game.load.image('fence', 'assets/jumpfence1.png'); game.load.image('track', 'assets/grasstrack1.png'); }, create: function() { this.jumpGroup = game.add.group(); this.timer = game.time.events.loop(12000, this.addNewJump, this); this.horseGroup = game.add.group(); this.horseGroup.enableBody = true; this.horseGroup.physicsBodyType = Phaser.Physics.ARCADE; this.addHorse(this); }, addHorse: function() { for (var i = 1; i <= 3; i++) { var posY = game.rnd.integerInRange(300, 500); var posX = game.rnd.integerInRange(30, 120); geegee = this.horseGroup.create(posX, posY, 'runner'+i); // Add 'sprite' to the group this.horseGroup.sort('y', Phaser.Group.SORT_ASCENDING); geegee.animations.add('gallop', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 20, true); geegee.animations.add('jump', [4, 11, 12, 13, 14, 15, 16, 17, 4], 14, false); } }, addJump: function(x, y) { var fence = game.add.sprite(x, y, 'fence'); this.jumpGroup.add(fence); game.physics.arcade.enable(fence); fence.body.setSize(50, 350, 105, 0); fence.body.velocity.x = -500; fence.checkWorldBounds = true; fence.outOfBoundsKill = true; }, addNewJump: function() { this.addJump(game.world.width - 40, this.game.height - this.game.cache.getImage('fence').height); }, update: function() { this.horseGroup.forEach(function(item) { // jump fences this.game.physics.arcade.overlap(this.horseGroup, this.jumpGroup, this.fenceJump, null, this); this.hurdle(); // move up and down field if (item.x > game.width - 650) { item.x = game.width - 650; item.body.velocity.x += game.rnd.integerInRange(-5, 0); } else { item.body.velocity.x += game.rnd.integerInRange(-5, 5); } if (item.x < 50) { item.x = 50; item.body.velocity.x = 0; } }.bind(this)); }, fenceJump: function(horseGroup,jumpGroup) { this.horseGroup.forEach(function(item) { item.body.velocity.y = 1; hurdleFence=false; }.bind(this)); }, hurdle: function() { this.horseGroup.forEach(function(item) { if(!this.hurdleFence){ //check if we already have -50 gravity or not if(item.body.velocity.y > 0){ item.events.onAnimationStart.add(airJump, this); function airJump() { item.body.velocity.x = 5; item.body.gravity.x = 100; } item.animations.play('jump'); item.events.onAnimationComplete.add(groundGallop, this); function groundGallop() { item.body.velocity.y = 0; } } else { item.animations.play('gallop'); } } }.bind(this)); }, };
  8. kurhlaa

    Tilemap tile's leave callback

    Hi, When we use a tilemap we are able to create callbacks to execute something when overlap/collision happens, with: layer.setTileIndexCallback(5, myFunction, this); But how do I execute something when I leave these specific tiles with ID 5 ?
  9. Hello everyone! I've been a lurker on this site for most of the time and the threads here helped me time and time again to sort things out. I'm currently trying to get a simple Jump'n'Run Game going, but I'm struggling with the collectibles. I'm using a Tiled Object Layer and imported it succesfully into the game. However, the overlap between the objects and the player just isn't working. I've tested the collectPoint1 function on another object and it worked. Also the sprites are all visible in my game. Really, the only problem is the overlap. class Level extends Phaser.Scene { constructor(){ super({ key: 'Level' }); }; create(){ let scene = this; let map = this.make.tilemap({ key: 'Level1'}); let player1_config = {...}; //Player 1 this.player1 = new Player1(this, player1_config); //Setting the score-data this.data.set('player1Score',0); //Animation of the Coins var coinSpin_config = { key: 'spin', frames: this.anims.generateFrameNumbers('coin', { start: 0, end: 7 }), frameRate: 10, repeat: -1 }; this.anims.create(coinSpin_config); //Using createFromObjects to display the coins this.points = map.createFromObjects('HousePoints', 'point', {key: 'coin'}, this); this.points.enableBody = true; this.anims.play('spin', this.points); //Score-text this.scoreText = this.add.text(30, 22, 'Score for ' + this.playerHouse + ': 0'); this.scoreText.setScrollFactor(0); }; //Collecting Points collectPoint1 (player, coin){ var score = this.data.get('player1Score'); this.data.set('player1Score', score + 10); this.scoreText.setText('Score: ' + this.data.get('player1Score')); coin.disableBody(); } update(){ this.player1.move(); this.physics.add.overlap(this.player1, this.points, this.collectPoint1, null, this); } } } As I'm well aware of this post, I've tried it with map.getObjectLayer as well. Didn't work. I'm a huge fan of this template, but its structure is so very different to mine that it down't really help me. . . . . this.housePoints = this.add.group(null); const objects = map.getObjectLayer('HousePoints'); let housePoints_config = { scene: this, collected: false } objects.objects.forEach( (point) => { //Creates a Points Object defined in a Points class (see below) point = new Points(this, housePoints_config); this.housePoints.add(point); }); . . . . . } update(){ this.player1.move(); //This throws the error 'spin is not a function', but that's not my focus this.housePoints.spin(); //This overlap doesn't work either this.physics.add.overlap(this.player1, this.housePoints, this.collectPoint1, null, this); } } ///////////////////////////////////////////// ///This is in another .js file naturally//// /////////////////////////////////////////// class Points extends Phaser.Physics.Arcade.Sprite { constructor(scene, config) { super(config.scene, config.x, config.y); config.scene.physics.world.enable(this); this.scene = config.scene; this.collected = config.collected; this.scene.add.existing(this); this.scene.physics.world.enable(this); var coinSpin_config = { key: 'spin', frames: this.anims.generateFrameNumbers('coin', { start: 0, end: 7 }), frameRate: 10, repeat: -1 }; this.anims.create(coinSpin_config); } spin(){ this.anims.play('spin', true); console.log('point updated'); } } I'd be eternally thankful for every tip! Thanks so much, if you decide to take the time to help me.
  10. Hello, Just a quick question. I want to kill any emitter particles that overlap with a sprite. I've tried: if(this.game.physics.arcade.overlap(this.emitter, this.sprite)) { this.emitter.removeChildAt(0); //and this.emitter.removeChild(); }
  11. paperjack

    Visibility of overlapping containers

    Hello, I am making an arena shooter multiplayer game with destroyable obstacles. You can see a pre-alpha here: http://mechsgame.s3-website.eu-west-2.amazonaws.com I have encountered a problem I'm not sure on how to proceed on and I surprisingly couldn't find any information on similar issues. My game will have tall walls and other obstacles which can potentially cover the player's character. I would like to make an effect similar to RTS games, where an outline or a shadow of the player is visible on top of the obstacle. See the below picture to get an idea of what I mean. My player container contains several sprites. I have a few ideas on how to do this, but I do not think they are optimal. One is rendering the player container to a texture and using that a mask for potential overlapping obstacles, along with a filter. Secondly is just placing a simple GUI marker that shows where the player character is. In both cases, I am unsure on how to detect overlapping sprites. Is there an established solution for such cases? Thanks!
  12. Hello, i have this code that should create in the create function if one of the sprites of the "asteroids" group is overlapping the station (so the player doesnt get instant killed when he spawn). It is working in the Asteroid.prototype.update function but to optimize the game i would like to check it in the create function. this.asteroids.forEach(function (item) { if (Phaser.Rectangle.intersects(this.station.getBounds(), item.getBounds())) { item.destroy(); } }, this); It isnt working as exepted, could soweone help me ?
  13. gesichtsfelsen

    How to check for certain touching.down

    Hi, i'm currently woriking on a litle Phaser side scroller. My problem is, my player can jump on items such as stars, and other things. I tried it with arcade.overlap like this: if (cursors.up.isDown && player1.body.touching.down && !game.physics.arcade.overlap(player1, stars)) { player1.body.velocity.y = -700; } But it didn't work for some reason... I didn't get any errors, but I can still jump on the stars. Does somebody have a solution for this?
  14. I'm trying to add some collectable coins : for(var i=0; i < coins.length; i++){ game.physics.arcade.overlap(coins[i].getSprite(), myPlayer.getSprite(), collectCoin, null, this); } Problem, in my callback function, I need to access to "coins", not only to his attached sprite, what can I do ? function collectCoin(coin, player){ coin.killCoin(); // play a "death animation" and destroy itself after 0.4s }
  15. I'm working on an action game where the player can touch certain switch tiles to turn other enemies off and back on. So the way it is supposed to work is like this: 1. The player overlaps a switch tile 2. Execute the switch action only once 3. Ignore further overlapping with that tile until player moves off 4. When player moves off the switch should wait for the next overlap 5. Repeat from step 1 when player overlaps again I'm using arcade physics and the overlap function and it's working.. sort of. The problem is, the overlap keeps firing over and over again. What would be the best way in Phaser to get the desired result? See screenshot below of what I mean, and I've created a sandox of my code example here: https://phaser.io/sandbox/edit/zEVOQfgA
  16. Hi guys, just a quick question. I'm trying to detect overlap between emitter particles and a group like so: create: function() { this.emitter = this.game.add.emitter(0, 0, 1000); this.emitter.enableBody = true; this.emitter.makeParticles('whiteParticle'); this.emitter.minParticleSpeed.setTo(100); this.emitter.maxParticleSpeed.setTo(800); this.emitter.gravity = 50; this.emitter.maxParticleScale = 3; this.emitter.minParticleScale = 0.1; this.emitter.setYSpeed(-150, 150); this.emitter.flow(1500, 100, 100, -1, false); //lifespan, frequency, quantity, total, immediate this.emitter.checkWorldBounds = true; this.emitter.outOfBoundsKill = true; this.fire = this.game.add.group(); this.fire.enableBody = true; this.fire3 = this.game.add.sprite(1423, 500, 'fireL3'); this.fire2 = this.game.add.sprite(1423, 500, 'fireL2'); this.fire1 = this.game.add.sprite(1423, 500, 'fireL1'); this.fire.add(this.fire3); this.fire.add(this.fire2); this.fire.add(this.fire1); }, update: function(){ this.game.physics.arcade.overlap(this.emitter, this.fire, this.damageFire, null, this); } damageFire: function(){ console.log('fire damaged!'); }, I can get this to work fine if I check for overlap between 2 sprites/groups, but I cannot get it to work for the emitter. Could anyone point me in the right direction? Thanks
  17. Kurapikax

    Collision problem

    Hello Phasers, I'm new to Phaser and I'm starting to have fun with it. But I have an issue with collision using Arcade physics. The problem is that when a collision happens between two bodies, the collision make them overlap a little bit and at some point the bodies pass through each other as you can see in this example. Adding the property bounce = 0 to the line body solve part of the problem. But their is style a slight overlap. Can somebody explain me what's happening and give me a solution to the problem ? Thanks.
  18. I'm currently making my first ever game and am fairly new to coding so I apologize if this code doesn't make much sense. In my game the player sprite changes with the collection of various items. When a certain item is collected I want it so that the score increases when the player is in a certain zone and decreases when the player is out of that zone all while the player sprite is that specific model, and then I want the score to decrease if the player is in that zone while the sprite model isn't correct. (Sorry if that doesn't make sense!) Here is what I have so far: //in the update function: game.physics.arcade.overlap(player, laneC, laneCScoreModifier, null, this); //outside update function: function laneCScoreModifier (player, lane) { if (player.key == 'heroc') { timer = setInterval(plusScore, 1000); if (! game.physics.arcade.overlap(player, laneC)){ clearInterval(timer); } } else { timer = setInterval(minusScore, 1000); if (player.key == 'heroc') { clearInterval(timer); timer = setInterval(plusScore, 1000); if (!game.physics.arcade.overlap(player, laneC)){ clearInterval(timer); } } } } function plusScore(){ score++; } function minusScore(){ score--; } So my first guess is the '!' modifier isn't doing anything there. When I run the game once the player enters the zone while not having the correct sprite the timer never stops, even if they leave. Anyone have any idea how I should approach this? Any help will be greatly appreciated!
  19. I want to check how much of my second sprite is overlapped with first sprite in callback function,so that i can determine if the overlap is enough for(% of overlapping) for further process.But when i check that with overlapY/overlapX .i am getting 0 always .Please help.
  20. Hi, in my finished game I've found a thing, that slows my game from 60 to 30 fps. Too many collisions handlers. Well I need them to control whole game, to call all essentiall functions, but they are sloooooowing game drastically. game.physics.arcade.collide(bullets, layer, resetBullet); game.physics.arcade.collide(grenades, layer, resetBullet); game.physics.arcade.collide(ebullets, layer, resetBullet); game.physics.arcade.collide(chest3, chest5, chesting); game.physics.arcade.overlap(bullets, ebullets, resetBullet); It's for bullets to destroy chests, bullets with themselves and chest with chest. If I delete this, FPS goes from 30 to 60. But I need this. How can I do it? It's interesting, because the bullets aren't even created and they are slowing game. I have much more collision handlers, for every object to collide with layers and with all other objects like player, bullet, chest, another bullet, enemy bullet etc... Full code of game is avaiable here: redplanetgame.prv.pl
  21. Hi friends. I want to activate a function when two objects overlap. For example when I overlap an object I want to change gravity of a specific area. I can do this with overlap but it does it for one time, after that everything is same again. For example in the game, I will overlap a potion and gravity between position x1 and x2 will be equal -50. But when I do this, I mean when I overlap the potion, it occurs for one second and after that the gravity -50 turns back its past value.
  22. Hi, I would like to know if it is possible to create a function which asks if a sprite (playerA) overlaps with an object from a JSON tilemap without sprite? If my playerA overlaps this invisible object a function would be started. I already tried the overlap function between two sprites and it worked: function onDragStop(sprite, pointer) { if (checkOverlap(playerA,sprite)){ console.log("Overlap!"); } else { console.log("Dropped"); } function checkOverlap(spriteA, spriteB) { var boundsA = spriteA.getBounds(); var boundsB = spriteB.getBounds(); return Phaser.Rectangle.intersects(boundsA, boundsB); } Here is an extract of the JSON tilemap. { "height":10, "layers":[ { "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "height":10, "name":"Calque de Tile 1", "opacity":1, "type":"tilelayer", "visible":true, "width":20, "x":0, "y":0 }, { "image":"..\/world.png", "name":"World base", "opacity":1, "type":"imagelayer", "visible":true, "x":0, "y":0 }, { "draworder":"topdown", "name":"First Object", "objects":[ { "gid":1, "height":64, "id":5, "name":"", "rotation":0, "type":"", "visible":true, "width":64, "x":317.52500448109, "y":195.111668757842 }], "opacity":1, "type":"objectgroup", "visible":true, "x":0, "y":0 }, { "draworder":"topdown", "name":"Second Object", "objects":[ { "gid":1, "height":64, "id":11, "name":"", "rotation":0, "type":"", "visible":true, "width":64, "x":449.212619275898, "y":193.621695658129 }], "opacity":1, "type":"objectgroup", "visible":true, "x":0, "y":0 }, And I would like to play a sound when the player overlaps an object, and each object would have a different effect. And then I don't know how to specificaly call one object and check if it's overlaping with the player. objects = game.add.group(); objects.enableBody=true; game.load.tilemap('world',"assets/map/world.json",null,Phaser.Tilemap.TILED_JSON); game.load.image('tileset',"assets/world.png"); world = this.add.tilemap('world'); world.addTilesetImage('tileset','tileset'); layer = world.createLayer('Calque de Tile 1'); layer.resizeWorld(); world.createFromObjects('First Object',1,'',0,true,false,objects); I don't knwo if these parts of code are enough to understand what I would like to do? I don't know where to get the informations and documentation about that =/ Any information is welcomed ^^.
  23. mkhan074

    Body Overlap Detection

    Hi everyone, I am new to Phaser framework and it's great! I have made a lot of progress on this Street Fighter game I am doing. A little background of my problem: I have my code set up that when I press W (Medium Punch), I increase the width of the sprite by via setRectangle playerKen.body.setRectangle(70, 80, -18); once I expanded the hitbox , I play the sprite, then set the width back to its original size once the animation has finished playing: kenAnimation = playerKen.animations.play('standingMediumPunch', 10, false).onComplete.add(function () { //reset the graphics back playerKen.body.setRectangle(35, 80, -18); playerKen.body.setCollisionGroup(kenCollisionGroup); playerKen.body.collides(mBisonCollisionGroup, hitEnemy, this); kenAttacking = false; playerKen.body.velocity.x = 0; playerKen.animations.play('standing', 7, true); playerKen.body.static = false; //console.log('punching'); }, this); I have also programmed the AI too, won't get into that. But my issue is the overlapping hitboxes. See the attached photo... When a situation like this occurs when I am punching and the AI is punching as well, the health of the player and the AI does not decrease. I looked into https://phaser.io/examples/v2/sprites/overlap-without-physics but the getBounds() method only gets the width of the sprite, not the hitbox. How can I see whether the two hitboxes have intersected? By the way, I am using p2 physics. Thanks a bunch!
  24. jeroencoessens

    Checking nearby tiles

    Hi, I'm making a tile based mahjong clone, you can check the attached image for reference. basically I need a smart way to implement the mechanic of mahjong, that checks when I tap a tile if he has neighbours ( left or right ) and if he has a tile ontop of him. The way these are placed makes it very difficult for me to come up with a system. The sprites/buttons are all overlapping already I have my buttons(tiles) in an array and the references to which tile it is in a seperate array so I can create them easily for more levels. Is there someone who can help me tell phaser to check this without giving each tile in each level a reference to neighbours ( would take forever ) If you want me paste some code just ask
  25. smdu57

    Get Id of object in group

    Hello I'm using an overlap between player (joueur) and bottles (bouteilles). bottles is a group of 4 bottle and I want to know which bottle I'm interacting with in the function called by the overlap game.physics.arcade.overlap(joueur,bouteilles,interragitb,null,this); then the function function interragitb(joueur,bouteille){ cursors = game.input.keyboard.createCursorKeys(); if (cursors.up.isDown && points > 0) { bouteille.frame = bouteille.frame +1; point(0); } } and I want to increment a variable to know how many times I interracted with a spécific bottle how should I do ? Is there any way to get index in the group or var name ? Thank you