Jump to content

Search the Community

Showing results for tags 'collision detection'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

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

  1. Use case: simple particle simulation with collision detection. Think billiards. For what I'm doing i prefer doing it myself. In fact i have done this in the past. So I'm looking for a refresher tutorial. Would also consider using a physics library. The only concern there is bundle size. It's for a web app so i need to keep download size to a minimum.
  2. Hi folks, I'm new to this forum but I was wondering if someone could point me in the right direction or to a tutorial that'll help me out? I can't seem to get the collision detection to work here. This is my code: var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }, true); function preload() { game.load.image('shot', 'assets/sprites/drop.png'); game.load.image('spaceship', 'assets/sprites/spaceship.png'); game.load.image('glass', 'assets/sprites/glass.png'); game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; } var spaceship; var glass; var shot; var cursors; var fireButton; function create() { // Creates 1 single bullet, using the 'shot' graphic shot = game.add.weapon(1, 'shot'); game.physics.arcade.enable(shot); // The shot will be automatically killed when it leaves the world bounds shot.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS; // Because our shot is drawn facing up, we need to offset its rotation: shot.bulletAngleOffset = 90; // The speed at which the shot is fired shot.bulletSpeed = -600; spaceship = this.add.sprite(320, 20, 'spaceship'); game.physics.arcade.enable(spaceship); glass = this.add.sprite(320, 310, 'glass'); game.physics.arcade.enable(glass); // Tell the Weapon to track the 'player' Sprite, offset by 14px horizontally, 0 vertically shot.trackSprite(spaceship, 100, 180); cursors = this.input.keyboard.createCursorKeys(); fireButton = this.input.keyboard.addKey(Phaser.KeyCode.SPACEBAR); } function update() { // object1, object2, collideCallback, processCallback, callbackContext game.physics.arcade.overlap(shot, glass, collisionHandler, null, this); spaceship.body.velocity.x = 0; if (cursors.left.isDown) { spaceship.body.velocity.x = -300; } else if (cursors.right.isDown) { spaceship.body.velocity.x = 300; } if (fireButton.isDown) { shot.fire(); } } function collisionHandler(obj1, obj2) { // The two sprites are colliding // shot.kill(); shot.destroy(); console.log("collision"); } function render() { shot.debug(); } If anyone could help that'd be great! Kind regards!
  3. Hello community, I'm new to babylonjs and I have a question concerning to the collision detection of holes in meshes. I want to recognize that a sphere flies through a hole (any kind of shape possible). I prepared a example with an cylinder which contains some holes (different shapes) at a random position. A sphere is moving up and down to collide with the cylinder and I want to know, if that sphere collides with a hole or with the surface of the mesh object. https://www.babylonjs-playground.com/indexStable.html#1ZQS9W#6 At the moment, the collision with the mesh object changes the color of the sphere on any 'collision'. My goal is, that the sphere changes the color only passing/flying through a hole, but the holes can be random positioned and could also have a random shape. It would be great if you guys can help/teach me how to achieves this.
  4. Hi everyone, I just wanted to share a new Phaser Plugin called phaser-tilemap-plus, that extends the tilemap loader and factory to support tile animations defined in the Tiled editor. It also allows you to implement collision detection against the map using polygons and rectangles within an object layer, enabling the use of sloped and curved surfaces. It will eventually also support custom properties and region-based events via the object layer. You can access and build the library from GitHub or install it directly as a Node package via NPM. Please note that it is still a work in progress, with features that are yet to be added and kinks to iron out. Anyhow, let me know what you think!
  5. Hi guys, I've been digging through the code, examples and the forums and I'm yet to discover a solution to my problem. I have an array of objects and have set their collision properties as follows: this.physics.add.overlap(this.ball, this.bricks, this.hitBrick, null, this); What I need is to be able to dynamically change the collision type to something like: this.physics.add.collider(this.ball, this.bricks, this.hitBrick, null, this); Is there any way I can achieve that? Many thanks
  6. I am having some problems with a game where players enter safe and danger zones... some of these areas have sprites that are angled (rotated) but appear to fire collision when the 'character' sprite collides with their total X Y rectangle space (ie minXpoint to maxXpoint, minYpoint to maxYpoint)[imagine an angled rectangle pushing out its boundaries by its 4 corners] would this be right? Or am I having other issues? TO counter act i guess I will have to create n number of collision boxes (sides parallel to X-Y axe) overlapping along angleX.
  7. Hello, I am making a game using this tutorial: https://gamedevacademy.org/how-to-make-an-infinitely-scrolling-game-with-phaser/ I made some changes to it using the Phaser Basic Project template. I am having a problem with the collision detection. In the update function I have these lines detecting if a collision has happened: update: function () { console.log("in the update function!!!!!!!!!"); // Honestly, just about anything could go here. It's YOUR game after all. // Eat your heart out! // player land on ground instead of falling through this.game.physics.arcade.collide(this.player, this.ground, this.playerHit, null, this); // player bitten by a flea this.game.physics.arcade.collide(this.player, this.fleas, this.playerBit, null, this); // player can overlap with dirt mounds this.game.physics.arcade.overlap(this.player, this.mounds, this.collect, this.checkDig, this); This collision mechanism works as long as the player does not collide with a flea or digs. (I guess this means the collision mechanism does not work.) For example when the player collides with a flea, this.playerBit is called: playerBit: function (player, flea) { //remove the flea that bit our player so it is no longer in the way flea.destroy(); //update our stats this.scratches++; this.refreshStats(); //change sprite image this.player.loadTexture('playerScratch'); this.player.animations.play('scratch', 10, true); //play whine audio this.whineSound.play(); //wait a couple of seconds for the scratch animation to play before continuing this.stopped = true; this.player.body.velocity.x = 0; this.game.time.events.add(Phaser.Timer.SECOND * 2, this.playerScratch, this); }, refreshStats: function () { this.pointsText.text = this.points; this.fleasText.text = this.maxScratches - this.scratches; }, playerScratch: function () { this.stopped = false; // check the number of scratches, if 5 or greater // the player dies if (this.scratches >= 5) { console.log("scratches greater than 4"); this.player.alive = false; // reset world, this.fleas.destroy(); this.mounds.destroy(); this.player.loadTexture('dog'); this.player.animations.play('walk', 10, true); this.player.body.setSize(this.player.standDimensions.width, this.player.standDimensions.height); //.. then run home this.player.anchor.setTo(.5, 1); this.player.scale.x = -1; this.player.body.velocity.x = -1000; // run off the screen this.game.camera.unfollow(); //..then go to Game Over state this.game.time.events.add(15000, this.gameOver, this); } else { console.log("in the playerScratch function!!!!!!!!!"); this.player.loadTexture('dog'); this.player.animations.play('walk', 3, true); this.player.body.setSize(this.player.standDimensions.width, this.player.standDimensions.height); } console.log("leaving the playerScratch function"); }, After the player scratches, the player sinks below the ground. Why is this? Here is the update function : update: function () { console.log("in the update function!!!!!!!!!"); // Honestly, just about anything could go here. It's YOUR game after all. // Eat your heart out! // player land on ground instead of falling through this.game.physics.arcade.collide(this.player, this.ground, this.playerHit, null, this); // player bitten by a flea this.game.physics.arcade.collide(this.player, this.fleas, this.playerBit, null, this); // player can overlap with dirt mounds this.game.physics.arcade.overlap(this.player, this.mounds, this.collect, this.checkDig, this); //only respond to keys and keep the speed if the player is alive if (this.player.alive && !this.stopped) { this.player.body.velocity.x = 250; //We do a little math to determine whether the game world has wrapped around. //If so, we want to destroy everything and regenerate, so the game will remain random if (!this.wrapping && this.player.x < this.game.width) { //Not used yet, but may be useful to know how many times we've wrapped this.wraps++; // once we wrap we want to destroy everything and regenerate the world this.wrapping = true; this.fleas.destroy(); this.generateFleas(); this.mounds.destroy(); this.generateMounds(); // then put things back in the correct order this.game.world.bringToTop(this.grass); this.game.world.bringToTop(this.mounds); this.game.world.bringToTop(this.ground); } else if (this.player.x >= this.game.width) { this.wrapping = false; } //take the appropriate action for swiping up or pressing up arrow on keyboard //we don't wait until the swipe is finished (this.swipe.isUp), // because of latency problems (it takes too long to jump before hitting a flea) if (this.swipe.isDown && (this.swipe.positionDown.y > this.swipe.position.y)) { this.playerJump(); } else if (this.cursors.up.isDown) { this.playerJump(); } //The game world is infinite in the x-direction, so we wrap around. //We subtract padding so the player will remain in the middle of the screen when //wrapping, rather than going to the end of the screen first. this.game.world.wrap(this.player, -(this.game.width / 2), false, true, false); } },
  8. This has to be a FAQ, but I did not find an answer from a quick search. I will number the questions for reference. 1. If I want a sprite to have a separate collision rectangle that is smaller than the size of the sprite, how is that done in Phaser? 2. What if I want to have more than one collision rectangle for an unusual shape? 3. What if I want to check for collisions with triangles, circles, ellipses, etc? Are there ready-to-go functions for these situations? If not, where would I plug in a handwritten algorithm? 4. If I wanted to have thousands of objects running around a huge map, does Phaser come with an algorithm to cut down the search space for each object's collision detection or is there a good third-party library to use for this situation?
  9. Hello all, I've been working through a project (using a lot of advice I've found from lurking here) and I've run into an issue. My goals are pretty modest; I'm trying to 1) have a natural jumping mechanism, and 2) have collision detection between the camera, ground, walls, etc. At first I did this just using Babylon's .checkCollisions, which works very well for camera vs object and camera vs wall collisions. However, I couldn't get this to work properly for jumping. Even following other's tutorials, (http://www.html5gamedevs.com/topic/12198-camera-jump/) I wasn't getting the results I wanted; on my computer, at least, all of those playground sketches still "hang" at the top of the jump until other arrows are pressed. So, I switched gears and tried using Oimo and Cannon. I still can't get Oimo to work, for some reason ( "this.world.worldscale is not a function" ring a bell for anyone? I can't find anything on that) but I've had decent results with Cannon. In short, I have the jump working, but now the collisions vs the walls are all...funky. Check out the playground sketch here- if you hit the wall, everything spins like mad. https://www.babylonjs-playground.com/#GYZQLK#3 I'm pretty stuck. I don't see how this collision detection is any different than between the ground and the camera, but something is obviously off. I've tried vs other horizontal objects (boxes, spheres) and had the best results setting the camera's physics imposter to a box (which makes turning all jittery). Any suggestions or ideas? Thanks all!
  10. Hi all, I'm working on a little racing game and using this map: I'm using p2 physics. Whenever the car touches the gras it should become slower. In order to achieve that I cut out the inner gras and created a polygon shape for it. /*Adding car*/ car = game.add.sprite(1100,300,'car'); car.name="car"; car.width=100; car.height=175; game.physics.p2.enable(car); car.body.angle = 90; game.camera.follow(car); inner_gras = game.add.sprite(1320, 940, 'gras'); game.physics.p2.enable(inner_gras); inner_gras.body.kinematic = true; inner_gras.body.clearShapes(); inner_gras.body.loadPolygon('collision', 'inner_gras'); inner_gras.name="inner_gras"; For the collision detection I use game.physics.p2.setPostBroadphaseCallback(): game.physics.p2.setPostBroadphaseCallback(hitGras, this); function hitGras(body1,body2){ if((body1.sprite.name === "inner_gras" && body2.sprite.name === "car") ||(body1.sprite.name === "car" && body2.sprite.name === "inner_gras")){ console.log(body1);//console.log(body2.sprite); return true; } else{ return false; } } The collision detection works fine, but whenever I try to do something else than returning true, for example changing the speed or something else, a contact between the car and the inner_gras sprite is detected, where they shouldn't have any contact. It seems like the inner_gras sprite does still have the rectangular shape, although applying clearShapes(). Any ideas or suggestions on how to solve this problem, or what to use instead? Thanks in advance!
  11. hi all, When ever we make collision check it will take the width and height of the image or object which we are giving . Now can we change width and height of the collision check alone .in my case my image size is 100*100 but while dragging and droping i am making collision check in which it taking 100*100 for check but i wana change it to 200*200 can it be possible . i tried changing the image with and height while dragstart,dragmove and pointerdown ,but still for collision it will take 100*100 only
  12. Hi, I'm running into an issue regarding collision detection against adjacent DisplayObjects. Let's say I have sibling objects that are a child of a Container that has been rotated. If I use getBounds() on the siblings they return a bounding box that is oriented to cardinal north. Using those bounds for collision detection may result in false positives, because the given bounds may not follow the actual shape and orientation of the DisplayObject. I created a codepen to illustrate the point: When you toggle the "rotate" buttons at the bottom of the pen you will see the purple box morphing to the shape of the bounds for "shape" and "label". The text will change from red to green if the collision detection returns positive. I would like to do a more robust collision detection algorithm (possibly based on Separating Axis Theorem), but I would need to grab the vertices for each shape correctly translated to the global coordinates regardless of their nesting within the scene graph (accounting for scale, rotation, and translation from the shape and all parent transforms). The case being that the collision detection that I would like to do may not be only between direct siblings within the scene graph. Is there a nested property that would give me what I'm looking for, or will I need to grab the graphics data and apply all of the recursive parent transforms myself for each vertex? Here is a fork of a codepen that demonstrates the Separating Axis Theorem:
  13. Hey! I have a group of enemies created like this (called from create()): spawnEnemies: function(map){ this.enemies = this.game.add.group(); this.enemies.enableBody = true; this.game.physics.arcade.enable(this.enemies); var enemyStartPositions = this.findObjectsByType('enemyStart', this.map, 'objectLayer'); for(var i = 0; i < enemyStartPositions.length; i++){ var enemyStart = enemyStartPositions[i]; var enemy = new Enemy(this.game, enemyStart.x, enemyStart.y, 'cultist'); enemy.countStats(); this.enemies.add(enemy); } this.enemies.setAll("body.immovable", true); } In the update function - I try to detect the collision between the children in the group like in this example (using 2.4.7): http://examples.phaser.io/_site/view_full.html?d=arcade physics&f=group vs self.js&t=group vs self&phaser_version=v2.4.7& this.game.physics.arcade.collide(this.enemies); But they wont collide with - just passing trough - each other. Also tried with adding a callback as when I let the player sprite collide with the enemy group like this: this.game.physics.arcade.collide(this.player, this.enemies, this.collisionHandlerPlayerAndEnemy, null, this); this.game.physics.arcade.collide(this.enemies, null, this.collisionHandlerEnemyAndEnemy); And the callback-function will not be called (may it be that this does not even work at all when the case is group to group?). I need someone elses eyes on this. No properties for enemy body is set outside these code blocks.
  14. Hey guys... Anybody got on insights on how the mesh.onPhysicsColiide property is supposed to work ??? I have this code to detect when two meshes with physics state enabled collide with each other. Now in the scene... both mesh actually do collide and bounce off each other like it should... but the the mesh.onPhysicsCollide property i set is NOT firing off. Here is code to log the collision event to the console (BUT I GET NOTHING ) // Physcis collision this.mesh.onPhysicsCollide = (collider:BABYLON.AbstractMesh, contact:any) => { console.log("*** HOLY SHIT - I GOT COLLISION ***"); console.log(collider); }; Any thoughts ???
  15. I really need to be able to hook into physics collision detection... There used to be a mesh.onPhysicsCollide that would have worked perfectly for my collision detection system (I basically don't require the imposter filter part for collision detection... I will filter based off mesh.metadata tags). Now using the registerOnPyhsicsCollide DOES NOT WORK without some kind of imposter (even with the otherImposter.length === 0). The problem is the unregister DOES NOT find if you pass null imposter or empty imposter array... you gotta pass an actual imposter to filter or you WONT be able to unregister.... and you will leak. I need basic collision detection support... I will handle (filter) what should be imposter collision event should get dispatched. I suggest the SMALL change to the babylon.physicsImpostor class: /** * Legacy collision detection event support */ public onCollideEvent: (collider:BABYLON.PhysicsImpostor, collidedWith:BABYLON.PhysicsImpostor) => void = null; //event and body object due to cannon's event-based architecture. public onCollide = (e: { body: any }) => { var otherImpostor = this._physicsEngine.getImpostorWithPhysicsBody(e.body); if (otherImpostor) { // Legacy collision detection event support if (this.onCollideEvent) { this.onCollideEvent(this, otherImpostor); } if (!this._onPhysicsCollideCallbacks.length) return; this._onPhysicsCollideCallbacks.filter((obj) => { return obj.otherImpostors.indexOf(otherImpostor) !== -1 }).forEach((obj) => { obj.callback(this, otherImpostor); }) } } What do you think @Deltakosh @Sebavan @RaananW ... OR Should i just fork my own BabylonJS Toolkit Version of the framework... And i will just use my own build for the toolkit: /Assets/Babylon/Library/babyblon.bjs (Which might not be a BAD idea... At least i would have better control of the main babylonjs library and the API that is necessary for me to make the KOOL toolkit features i have been working on) I dunno ... Please folks... Weigh in your thoughts before i do anything drastic with the toolkit libraries
  16. Hi, I'm using Phaser (2.2.1) to make my first game, a platformer. Arcade physics to do the collision detection; Tiled to make the map. The problem I'm having is that the player occasionally passes through a platform when descending from a higher point (after jumping for example). Here are what I think are the relevant bits of code: Create: this.gravity = 2200;this.blockedLayer = this.map.createLayer('blockedLayer');this.map.setCollisionBetween(1,10000,true,'blockedLayer');this.player = this.add.sprite(200,200,'player');this.player.anchor.setTo(0.5,1);this.physics.arcade.enable(this.player);Update: this.game.physics.arcade.collide(this.player,this.blockedLayer);So to repeat -- it's working most of the time, but 1 jump in 8 results in the player falling down through a platform (including through the floor on occasion). Following the advice in this post I tried playing with TILE_BIAS but it just made the player act freaky around the platforms... Has anyone had this problem before? Any ideas how to fix it much appreciated.
  17. What is the best approach to determining what face of a mesh was hit in a collision? I'm creating a game in which there are very many meshes; they are platforms onto which the player can jump. But if the player hits the side of any platform, he dies. As far as I can think, there are two approaches here: 1. Find some way of determining which vertex set was hit, get the normal to it, and record whether the normal points in the (0,1,0) direction (OK) or otherwise (kills player). However, I can only find a way of telling when two meshes collide. The PhysicsImpostor.registerOnPhysicsCollide callback only tells me which meshes are hit. Perhaps once I have the two meshes there is a way to tell which vertex set of one mesh intersects which vertex set of another - but if such a function exists I couldn't find it. (Closest thing is the PickingInfo returned by AbstractMesh.intersects(Ray) - but that's not quite what I need, as far as I can tell). 2. Add additional meshes to the scene to "cover" the platforms. So I could for example add a plane to the top face of each platform and say that if the player collides with it then he's safe, otherwise if he collides only with the platform then he's not. This approach seems inefficient as it doubles the number of meshes. Also would it even work? Say there is a platform that's a cube, and the player hits the side with normal (0,0,-1). That should kill him, but if he hits it near the top he may also just touch the edge of the cover - which by the logic above would save him. Thanks for any pointers!
  18. After half a day of debugging, I am quite sure the issue is not in my code since it comes directly out of Phaser. I attached a screenshot. The characters collide at the green C marked position. But there is nothing to collide with. The <obj>.body.blocked.left property is set to true >> so they are colliding left This shouldn't be possible. Since there is no object (green mark C) So I debugged the Phaser functions for collision. The call comes out of: https://github.com/photonstorm/phaser/blob/v2.6.2/src/physics/arcade/TilemapCollision.js#L356 (thanks to @Claudiovc ) processTileSeparationX is called from: https://github.com/photonstorm/phaser/blob/v2.6.2/src/physics/arcade/TilemapCollision.js#L242 were I passed in the >tile< parameter to processTileSeparationX and logged it. You can see that in the console window in the screenshot. The data on this tile shows that the ground-tiles are causing the <obj>.body.blocked.left = true. This Tile is marked red T. This is a possible bug. I also tested all the tile data, which you can see is on debug mode. Every tile (debug mode) aligns on the same pixel on the Y axis. So there is no "step" in it. The reason to assume it is a bug is that the collision on the left is called not <obj>.body.blocked.down Any further thoughts or already investigations on that - or am I completely wrong regards **EDIT** You can also test this with collision enabled only for top / bottom, then the floor tiles wont fire the collision. So I assume this is indeed some issue with the collision detection within phaser.
  19. Hi, I need to implement a check that can determine if a bounding box is completely inside a set of bounding boxes. See my attached graphic for a better understanding of the situation. I am thinking of consuming the A to B paths on each axis of the original bounding box using the axes limits of the containing bounding boxes. Then, for each axis, I would store those in an array, sort them by starting point, find if there are overlaps, eliminate them, find gaps (could probably happen if outer bounding boxes are not adjacent to each other) and if none are there, look if the total length is the length of the object bounding box. If this is the truth for every axis, then I can be sure that the item is completely inside the valid area. The only thing I am worried about is that this can become quiet slow. Since this is usually an edge case, I would first go through all container bounding boxes and see if the object is completely inside one of them. Only if that is not true, I need to do the more complex check. Any ideas on different, maybe faster algorithms? Regards Jacques
  20. I have been working with Phaser for about 6 months now, and have recently purchased the Box2D plugin, and for the most part its great, although I am having a few basic problems with spawning the sprite with an appropriately sized body, then applying a continuous velocity. Below is the offending function. First a sprite is spawned from a loaded atlas (the zombie), but unfortunately the sprite is way too big (or my game is too small, one of them) and needs to be scaled down to a 1/4 of its original size. I found a question elsewhere on here where someone (it may have even been Rich) gave an answer to define the body separately, then reattach it to the sprite and the sprite to it. This appears to work fine-ish, giving me a body that is registered as the sprite's and collides properly etc etc. On spawn the zombie plays an anim of pulling itself out of the ground (the spawn anim), and then when that is completed it should play the walk animation, then actually move. The commented section within the OnComplete callback shows all of the different methods of getting something to move in Box2D the internet can give me, but none of them work. function spawnZombie(x, y){ var zombie = zombies.create(x, y, 'zombie'); zombie.anchor.setTo(0.5, 0.5); zombie.scale.setTo(0.25, 0.25); var zomBody = new Phaser.Physics.Box2D.Body(this.game, null, x, y, 0.5); zomBody.setRectangle(30, 50, 0, 0, 0); zombie.animations.add('spawn', Phaser.Animation.generateFrameNames('appear/appear_', 1, 11, '', 1), 7, false); zombie.animations.add('walk', Phaser.Animation.generateFrameNames('walk/go_', 1, 10, '', 1), 7, true); zomBody.sprite = zombie; zombie.body = zomBody; zombie.animations.play('spawn'); zombie.events.onAnimationComplete.add(function(){ zombie.animations.play('walk'); //zombie.body.velocity.x = -100; //zombie.body.moveLeft(100); //zomBody.moveLeft(100); //zomBody.velocity.x = -100; console.log(zombie); }, this); } Personally I think that the problem lies with the body being set as it is, as this method feels like a buggy workaround to me. The only symptom of the problem I can see within the sprite object is that setting the velocity actually does nothing, whereas elsewhere in the code it works as expected. I wouldn't be exaggerating if i said i had spent 6 hours on this problem, and I'm about 2 hours away from quitting my job forever and ritually burning my PC. Any help at all would be great, cheers.
  21. Hi all, I'm making a mobile game and looking for the most efficient way of going about coding the following. Any comments would be most welcome 1. A solid background image Is this just a sprite of an optimized bitmap? Or is there a special method for bg images that keeps them as efficient as possible. 2. Generate a lot of balls (sprites) that bounce around the screen (Currently created a group for the balls and MANUALLY checking for boundary collisions to avoid the overhead of any physics engine). Am I being too harsh here? Will ARCADE physics do a better job of it, efficiency wise? 3. I need to check collisions with the touch/click co-ordinates at a given moment with all these balls, even if they overlap, a click will be detected regardless of layers. My initial thoughts are to engage quad trees to elect candidates for running collision detection on. I have this function too, to detect clicks in a circle: // Check if the input is within a circular radiuscheckCollision: function(ball, inputX, inputY) {var radius = ball.width/2var centerX = ball.x+radius;var centerY = ball.y+radius;if(Math.sqrt((inputX-centerX)*(inputX-centerX) + (inputY-centerY)*(inputY-centerY)) < radius) {return true;} else {return false;}},I'm having trouble relating the sprites in a group to candidates that are retrieved from a quadtree, is the quadtree built into groups? Say if a candidate came back from the quadtree, and collision was true, how would I kill the sprite from the group? Any pointers would be great! Thanks guys, Phaser is really great to work with.
  22. Hello all, I'm trying to make a "game" in which you drag sticks from a pool and you position them on the screen. (I'm basicaly creating a cuisenaire program). The sticks have to be restrained in the underneath tilemap and also cannot overlap with each other. Every stick has a sprite.input.enableDrag(); sprite.input.enableSnap(30, 30, true, true); So it can be draggable. Also, I whenever the user drags a stick from the pool, I clone a stick there so he can drag another one later on. How can I instruct phaser to watch for collisions between all sticks? If I put them on a group, I loose the input.enableDrag on every stick. If I don't have them on a group, how can I reference them to watch for collisions with each other? Thank you
  23. I am making a game, everything works except the physics system? Collisions and Gravity are in the code but don’t seem to work. Using breakpoints, it gets to all the pieces of code but never actually works. I have tried to frantically make it work (Thats why theres so much physics code in the file). Can anyone please help me? This is the code that I think you will need: http://pastebin.com/0Sh8pqVJ This is all of the code together: http://pastebin.com/CfFuatdt Thanks.
  24. Hey there, my game consists of a player implemented with P2 and enemies implemented with Arcade physics (for better performance, since the AABB is sufficient for them). How can I detect collision between the Arcade bodies and the P2 body/bodies ? (The point is: I want the enemies to bounce away) OR: I've read in some other thread, that P2 offers AABB. I've searched the Phaser docs, but I didn't find anything helpful. Can you recommend a way to implement the described above only with P2, without affecting performance? Thank you guys in advance!
  25. I'm trying to detect a possible collision between objects that could be stationary or moving in any direction (angle). 1. I want the object to be notified when a particle/object is inbound for collision. Essentially, I want to introduce AI where the object will take action when it is shot at or an enemy is approaching. 2. Another use-case is for scanning. I'd like an entity to be able to spot its enemies and get info like distance, velocity, type, etc. I've read through the documentation, examples, posts on the forum and searched online, but I've clearly missed something. Does anyone know a way to accomplish the above? Thanks!
×
×
  • Create New...