collision-detection

Swift SpriteKit basic Contact / Collision

放肆的年华 提交于 2019-12-13 07:15:12
问题 The problem: When the coin spawns, it's physicsBody appears right underneath the spriteNode. Also, when the player comes in contact with the coin's physicsBody, the player bounces off of the physicsBody and the game ends. What the output should be: The coin's physisBody should be aligned properly with the coin spriteNode. When the player comes in contact with the coin, the coin should disappear and +1 should be added to the proper label. The current code: struct ColliderType { static let

How do I detect the collison of components?

你。 提交于 2019-12-13 07:09:17
问题 How do I detect the collision of components, specifically JLabels (or ImageIcons?)? I have tried this: add(test1); test1.setLocation(x, y); add(test2); test1.setLocation(x1, y1); validate(); if(intersects(test1, test2)) { ehealth-=50; } public boolean intersects(JLabel testa, JLabel testb) { boolean b3 = false; if(testa.contains(testb.getX(), testb.getY())) { b3 = true; } return b3; } When I run this, it does nothing! I used to use Rectangle , but it didn't go well with me. I was thinking

Java - Sprite in JPanel error

时光毁灭记忆、已成空白 提交于 2019-12-13 04:44:39
问题 Every time i run the panel is filled with a white line in the corner of it and the rest is black. I would like to add KeyListener to the program so when i push the "W" key it will animate the sprite as it seems to be going forward. IF the sprite is not centered all the time than how would i code a collision detect to repaint the map when the sprite image block reaches the edge of the panel. I know im asking more than one question yet im tring to figure out one problem. How would i spawn a

Collision detection while using rectangles

五迷三道 提交于 2019-12-13 04:37:57
问题 So I understand that I'm not coding this the best way possible at the moment; this is a sort of test run. What I'm trying to do is wall collisions using rectangles and the intersects property (sorry if I'm not using the correct terminology). So far I have 2 rectangles on screen. 1 the player controls and the other which the play is colliding with. When they collide the player stops moving. The problem is that if the player is trying to move into the rectangle while they are already colliding

3D object falling through ARGroundPlane

萝らか妹 提交于 2019-12-13 03:56:13
问题 I`m using Vuforia plugin Unity, I added 3D Water can to my scene, and make it child to the Ground Plane Stage, when I run the game the object occurs, I add Box Colliders to both Ground Plane Stage and the Water can, also I add rigidbody to the can , when running the game the can fall through ground (doesn't stop falling ) How Can I fix this and make water can stop falling ? I use Vuforia 7.5.26 回答1: Okay the problem is your object starts falling when you press play regardless of whether you

How to do intersection with condition in C#?

有些话、适合烂在心里 提交于 2019-12-13 03:00:02
问题 I have a question about intersection or rather collision detection with condition. I am doing a collision detection between a bar(Image) and a ball(Image). The bar can be moved up and down upon user's response on dragging the bar. The collision detection codes are as below. public bool Intersects(Rect barRectangle, Rect blueBallRectangle) { barRectangle.Intersect(blueBallRectangle); if (barRectangle.IsEmpty) { return false; } else { return true; } } In private void OnUpdate(object sender,

Using Generic Functions for collision detection in C# / XNA

别等时光非礼了梦想. 提交于 2019-12-13 02:29:16
问题 I am making a physics engine in c# / XNA, I have three basic objects... Sphere Cube Plane that are all derived from GameObject I store all my objects in a list of GameObjects and I would like to loop through this list and be able to call a CheckCollision function that will go to the correct function for each pair of objects eg go is a Sphere, go2 is a Sphere if(CheckCollision(go, go2)) { //do stuff } bool CheckCollision(Sphere one, Sphere two) { //Check Sphere to Sphere } bool CheckCollision

Move a Box with another on colission respecting the next neighboring mesh in Three.js

有些话、适合烂在心里 提交于 2019-12-13 02:02:52
问题 Found a lot of physic engines out there but nothing that fit my needs directly. I try to to find a simple way to push and pull boxes including collision detection which respects the next neighboring mesh hit while moving. Some use cases to understand: All boxes except box 1 are moveable. Push or Pull box 4 to west: Should move box 3 to west on collision. Should make box 3 and 4 not able to move west when box 3 hits box 2. Push 2, 3 or 4 to north: Should stop when it hits box 2, because box 1

Uniform grid collision detection between circles in 2d

守給你的承諾、 提交于 2019-12-13 02:01:44
问题 I am working on a 2d arcade game where I have 5 types of circles with different sizes: The ship, the missiles, and 3 types of monsters. This is what it looks like: Currently I'm using brute force collision detection where I check every missile vs. every monster without taking probability of collision into account. Sadly, this makes the process REALLY slow. This here is my Grid class, but it's incomplete. I'd greatly appreciate your help. public class Grid { int rows; int cols; double

how do i have one physics body negate the collision of another.

不想你离开。 提交于 2019-12-13 01:39:13
问题 i have two images on the screen that overlap called A and B. i have a third image called C that the user is able to move around the screen. the bigger one (A) of the two resets the C to the spawn point on collide. i need to know how to make it so that C can walk over image B and not be reset to the spawn point. as in image B overlaps image A and negates the collision function. here is the code: --Hides status bar from top of page display.setStatusBar( display.HiddenStatusBar ) --Set a test