collision-detection

Get the upper, bottom, rightmost and leftmost point of a pixel-perfect BitmapData collision

给你一囗甜甜゛ 提交于 2019-12-13 18:11:02
问题 How can I get the upper, bottom, rightmost and leftmost point of a pixel-perfect BitmapData collision? This is my collision-detection code: public static function checkCollision(object1:*, object2:*, debug:Boolean = false):Boolean{ var object1Rect:Rectangle = object1.getRect(stage); var object2Rect:Rectangle = object2.getRect(stage); var object1Point:Point = new Point(object1Rect.x, object1Rect.y); var object2Point:Point = new Point(object2Rect.x, object2Rect.y); var bitmapData1:BitmapData =

Basic Swift SpriteKit Collisions using PhysicsBodys

社会主义新天地 提交于 2019-12-13 17:42:50
问题 The problem: I seem to be having a little trouble getting my player to collide with a coin, and adding +1 to a coinLabel upon the collision. The player should continue moving after coming in contact with the coin. What I have now: With the code I have now, the player travels through the coin, but there is no collision that takes place and +1 isn't added to the coin label. I am still learning the swift language, so I appreciate any help that is given. Code: struct ColliderType { static let

How to implement collision detection on nodes which are in StackPane (in JavaFX)?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 16:52:38
问题 I am trying to check collision detection on the nodes which are inside StackPane. Below is my code: public void start(Stage primaryStage) throws Exception { StackPane pane = new StackPane(); Scene scene = new Scene(pane,300,300,Color.GREEN); primaryStage.setScene(scene); primaryStage.show(); Rectangle rect1 = new Rectangle(50, 50); rect1.setFill(Color.BLUE); Rectangle rect2 = new Rectangle(50, 50); pane.getChildren().add(rect1); pane.getChildren().add(rect2); TranslateTransition

Tracking unique versions of files with hashes

拈花ヽ惹草 提交于 2019-12-13 15:09:12
问题 I'm going to be tracking different versions of potentially millions of different files, and my intent is to hash them to determine I've already seen that particular version of the file. Currently, I'm only using MD5 (the product is still in development, so it's never dealt with millions of files yet), which is clearly not long enough to avoid collisions. However, here's my question - Am I more likely to avoid collisions if I hash the file using two different methods and store both hashes (say

Rotating Images & Pixel Collision Detection

时间秒杀一切 提交于 2019-12-13 15:02:50
问题 I've got this game in this plunker. When the swords are not rotating, it all works fine (you can check by uncommenting lines 221 and commenting out 222-223). When they are rotating like in the plunker above, the collision doesn't work well. I guess that's because the "getImageData" remembers the old images, but I gather it's an expensive thing to recalculate over and over again. Is there a better way to rotate my images and make this work? Or do I have to recalculate their pixel map? Code of

Robot crosses boundary on collision rather than bounce back while implementing particle filter

匆匆过客 提交于 2019-12-13 10:23:39
问题 I have written the following code, where I am trying to create a particle filter. The problem I am facing is that even after using intersects method and other conditions, the robot sometimes overlaps the obstacles. Moreover, it goes out of boundary through upper left corner after wobbling again and again with the corner. I check for the collisions and then if it seems there is a collision I move the robot by amount x in the reverse direction. I calculate amount x by the following method,

IOS SpriteKit Colision Detection: Resetting Position of NSMutable array of Objects

醉酒当歌 提交于 2019-12-13 10:03:12
问题 I'm attempting to make a game with objects that bounce between the left and right walls of the screen until they reach the bottom. Currently, my working didBeginContact method looks like this: - (void)didBeginContact:(SKPhysicsContact *)contact { uint32_t collision = (contact.bodyA.categoryBitMask | contact.bodyB.categoryBitMask); if (collision == (crabCategory | leftWallCategory)) { // figure out which crab in the array made the contact... for(HHCrab *object in crabs) { if(([object.name

Ball sometimes bounces sometimes doesn't

拈花ヽ惹草 提交于 2019-12-13 09:06:32
问题 This code makes the ball bounce around the canvas: //advance the ball ball.advance(); //check if ball should bounce off canvas sides if (ball.getCenterX() + ball.getRadius() > canvas.getWidth()) ball.setDirectionX(LEFT); if (ball.getCenterX() - ball.getRadius() < 0) ball.setDirectionX(RIGHT); if (ball.getCenterY() + ball.getRadius() > canvas.getHeight()) ball.setDirectionY(UPWARDS); if (ball.getCenterY() - ball.getRadius() < 0) ball.setDirectionY(DOWNWARDS); Looks like this: https://gyazo.com

Collision detection (CGRectIntersectRect)

点点圈 提交于 2019-12-13 08:19:37
问题 I have two images: first image size is 50x85 and second image size is 50x113. When I touch the screen image goes up and second image is shown and when I release the screen image goes down and first image is shown. Now the problem is when I'm touching the screen collision happens earlier than when I'm not touching the screen. How could I make that in second image about 30px at bottom won't collide, but image will still be there? Edit: Here is some of the code: -(void)AstronautMove { [self

Detecting and using collision detection between two different arrays to remove instances of them

♀尐吖头ヾ 提交于 2019-12-13 07:30:19
问题 I'm currently creating a small flash game using ActionScript and after receiving help for another issue I had on here, I've encountered another one when moving onto a different part of it. This is the code I currently have: var asteroidSpeed = 5; var soundExplosion:Sound = new ExplosionSound(); stage.addEventListener(KeyboardEvent.KEY_DOWN, onKDown); var newLaser:Array = new Array(); function onKDown(e:KeyboardEvent):void { keys[e.keyCode] = true; if (e.keyCode == 32) { /*laser.x = player.x +