collision-detection

cocos2d sprite collision detection boundingbox

孤者浪人 提交于 2019-12-01 12:51:04
I got 2 sprites. I use the boundingbox to check for collision with CGRectIntersectsRect. But it is not working. HBBall and HBpaddle has a CCSprite called image. Init: ball = [[HBBall alloc] init]; ball.position = ccp(150, 50); [self addChild:ball]; [update addObject:ball]; paddle1 = [[HBPaddle alloc] init]; paddle1.position = ccp(50, 160); [self addChild:paddle1]; Update: if (CGRectIntersectsRect([paddle1.image boundingBox], [ball.image boundingBox])) CCLOG(@"ball hit paddle"); CGRectIntersectsRect retuns always true. Does anyone have an idea? you cant pass directly the bounding box, because

IOS 13 Sprite Kit Issues

六眼飞鱼酱① 提交于 2019-12-01 12:08:26
问题 I recently made a game using sprite kit xcode 10.2 which was working fine unless ios 13 update, I tested the game in xcode 11 simulators with ios 13 the fps of the game starts to get reduce to 30-35fps. Also sometimes physics body on sprite nodes is not working properly. sometimes collision is detected on sprite nodes and sometimes it is being detected in middle of the sprite node which was not the case in ios 12 everything was working fine until ios 13 update. 来源: https://stackoverflow.com

Pygame - sprite collision with sprite group

元气小坏坏 提交于 2019-12-01 11:13:40
I have created two simple sprites in PyGame and one of them is an Umbrella, the other one is a rain drop. The Raindrops are added into a sprite group called all_sprites . The Umbrella sprite has its own group called Umbrella_sprite The raindrops are "falling" from top of the screen and if one of them touches the umbrella / collides with it.. the raindrop is supposed to be deleted. BUT instead of that specific raindrops all other are affected by this. main file (rain.py) #!/usr/bin/python VERSION = "0.1" import os, sys, raindrop from os import path try: import pygame from pygame.locals import *

Box2D: How to get the position of a static body?

旧巷老猫 提交于 2019-12-01 10:11:14
问题 I have a Box2D world with a mixture of static and dynamic bodies. On collisions, I can only get the positions of the dynamic ones. Is it possible to get the positions of static objects? N.b., this is a development of a previous question, Box2D: How to get the position of a sensor? 回答1: I found a way - in the collision, the center of the AABB will give the position contact.GetFixtureA().GetAABB().GetCenter() 回答2: You can get the position vector using the following code: b2Transform t = body-

Collision detection : rounded object

给你一囗甜甜゛ 提交于 2019-12-01 09:20:01
问题 I'm developing a Java game (but the dev. language doesn't really matter) including rounded objects like balls or pucks, and now working on collisions. I use a timer, so on every frame I check if a collision happens. Here is a graph that represents the top-right piece of an object. The center of the object is represented by the point [0,0], its radius is 10px and the units are pixels. Now if my object (for example, obj_1 ) is square/diamond-shaped (blue line), to find if another one ( obj_2 )

Pygame - sprite collision with sprite group

人走茶凉 提交于 2019-12-01 08:46:53
问题 I have created two simple sprites in PyGame and one of them is an Umbrella, the other one is a rain drop. The Raindrops are added into a sprite group called all_sprites . The Umbrella sprite has its own group called Umbrella_sprite The raindrops are "falling" from top of the screen and if one of them touches the umbrella / collides with it.. the raindrop is supposed to be deleted. BUT instead of that specific raindrops all other are affected by this. main file (rain.py) #!/usr/bin/python

Swift Spritekit I detect a collison but it reads the collision mulitple times

痞子三分冷 提交于 2019-12-01 08:31:06
AppImage I have a wall of 4 rectangles that are different colors, to pass through the wall the color of the ball has to match that of the rectangle on the wall. The ball will pass through the wall, and a new wall will appear. However, when I detect this collision I get multiple collision readings. I have tested this by printing dead or alive, and it prints both or more many times. func didBegin(_ contact: SKPhysicsContact) { if let nodeA = contact.bodyA.node as? SKShapeNode, let nodeB = contact.bodyB.node as? SKShapeNode { if nodeA.fillColor != nodeB.fillColor { print("DEAD") } else { print(

Detecting if a specific sprite was touched on Cocos2d-iphone

巧了我就是萌 提交于 2019-12-01 08:19:43
I was following Ray`s tutorial for making a simple iPhone game (here: http://goo.gl/fwPi ) , and decided that i wanted the enemies to be eliminated when they get touched. My initial approach was to spawn a small CCSprite sprite on the touch location, then use CGRectMake to create a bounding box of said sprite to detect if the enemy sprite was touched. Much like Ray does with the projectile/enemy. But of course, my way of doing it isnt working and i cant dig myself out of this hole. Here is the relevant code snippet. Any help is appreciated: - (void)ccTouchesEnded:(NSSet *)touches withEvent:

Detecting collisions between rotated UIViews

坚强是说给别人听的谎言 提交于 2019-12-01 08:17:54
问题 I have two UIViews, one of which is rotated every .01 second using the following code: self.rectView.transform = CGAffineTransformRotate(self.rectView.transform, .05); Now, I want to be able to tell if another UIView, called view, intersects rectView. I used this code: if(CGRectIntersectsRect(self.rectView.frame, view.frame)) { //Intersection } There is a problem with this, however, as you probably know. Here is a screenshot: In this case, a collision is detected, even though obviously they

Collision with shapes other than rectangles..?

China☆狼群 提交于 2019-12-01 07:32:50
I'm so used to working just with rectangles for collision detection that I'm a bit stumped right now. I'm working with diamond-like shapes, and for the past few hours, have been trying to figure out how to check for collision. I tried checking to see if the first objects four points are inside the points of the second object, but that just makes a box (I think) The reason why I feel like I'm having difficulty with this is because of the angles. You're trying to collide a moving convex polygon (your "diamond") with another moving convex polygon, is that right? Something like this: Your first