collision-detection

Contact Listener not working in Libgdx

痞子三分冷 提交于 2019-12-12 01:55:22
问题 I am developing a game in Libgdx and I am working on collision detection between two bodies in box 2D. I used "Contact Listener" to detect collision but nothing happens when the bodies collide. This is my code public Player(World world,float x,float y,float width) { this.width=width; //IMP height=width*2; BodyDef polygon=new BodyDef(); polygon.type=BodyType.DynamicBody; polygon.position.set(x,y); // polygon.fixedRotation=true; PolygonShape poly =new PolygonShape(); poly.setAsBox(width/2

Maze collision detection with tiles AS3

天大地大妈咪最大 提交于 2019-12-12 01:12:23
问题 Hey guys so I created a maze with this code and I want to hitTest the walls but when i try something along the lines of if (mc.hitTestObject(tile)) it doesn't do anything. And I'm not sure why, here's the code : package { import flash.display.MovieClip; import flash.events.KeyboardEvent; import flash.events.Event; import flash.display.DisplayObject; public class Main extends MovieClip { private var mc:hero = new hero; private var tile:tile1 = new tile1; private var mcSpeed:uint = 5; private

Wrong repositioning circle after collision with segment with a vector algorithm

隐身守侯 提交于 2019-12-11 23:58:16
问题 In a 2D game, i'm trying to repositionate a circle after it passed through a segment. Taking the picture as example situation, i need to reposition back the circle so that B will become the tangent point on the circle. The informations that i have are: x,y of the circle Radius of the circle dirx, diry: Direction of x,y the circle is having Distance between A and B What i'm doing is to calculate the coordinates of point C, then coordinates of point B, and then subtract vector AB from AC

how I check collision with box2dlights in libgdx?

落爺英雄遲暮 提交于 2019-12-11 22:01:55
问题 It is possible to detect when a body is under light? ( Collision with the light and a body ) How I check this with libgdx? Sorry for my english... 回答1: It could be easy to implements with raycasting : With a point light, you have to perform a raycast from your body object to the light object, if the first returned body is the light then your object is under light. With a directional (infinite) light you have to raycast from your object body toward light direction opposite, if raycast not

Action Script 3. Animation loop forever after gotoAndStop() and have lag during animation when character have collisions

不羁岁月 提交于 2019-12-11 19:26:37
问题 I'm creating simple flash game. I have problem, animation loop forever after I user gotoAndStop() and I have lag when during animation if character have collision with ground or any stage (if character flying on the air don't have any lags) Here is collision list: var myCollisionList:CollisionList = new CollisionList(Hero); myCollisionList.addItem(ground); myCollisionList.addItem(ground3); myCollisionList.addItem(ground5); myCollisionList.addItem(ground4); And here is my part of code where

How to improve/fix collision detection between ball and paddle?

大城市里の小女人 提交于 2019-12-11 19:07:32
问题 Basically i am in the process of making a game which is like pong, breakout, etc. I am having some problems when the ball and paddle collide... but only sometimes! This video here is what is occuring: http://www.youtube.com/watch?v=uFZIxFIg0rI So yea, basically the ball sometimes seems to go a bit crazy when it collides with the paddle... normally if i am moving the paddle in the opposite direction of which the ball is approaching it. Also the ball sometimes get's caught between the bottom of

Canvas With Box Colliders Confusion

断了今生、忘了曾经 提交于 2019-12-11 17:52:44
问题 I have a canvas with Render Mode: Screen Space - Camera Inside that I have square objects that I want collisions to be detected based off world view game objects. (Reason for this they need to scale based off device screen size) I added a 2D box colliders to theses boxes but then get this error. Error: this collider will not function with an effector until there is at least one enabled 2D effector on this GameObject How can I detect Collisions of game objects in world view with tag "a" when

collision testing with multiple objects on stage

混江龙づ霸主 提交于 2019-12-11 17:13:58
问题 I'm trying to create a sort of tree diagram such that, if you click on one of the circles, its child circles spread outward with some degree of randomness from the original circle, connected by lines. I have this working, but now what I want to do is make sure that none of the circles collide with each other and none of the lines criss cross. You can see the screenshot for what is currently happening. My code is below. How do I change this code so that it checks for collisions and avoids them

Collision Detection in a List

不问归期 提交于 2019-12-11 14:56:16
问题 I'm new to collision detection and have been working on a brick breaker style game with Tkinter. Each of my bricks are created separately so instead of creating if statements for each of the 30+ bricks I put them in a list, however when I run the program the collision detection function doesn't work. Can someone please help I don't understand what is wrong in the code. from Tkinter import * root = Tk() drawpad = Canvas(root, width=600,height=600, background='white') player = drawpad.create

Making a ball bounce inside another ball

那年仲夏 提交于 2019-12-11 14:21:52
问题 There is plenty of information about how to make balls collide with one another on their outer boundaries, but I couldn't find anything that covers balls bouncing inside another ball . What would be the best way to accomplish this? I believe many people would benefit from this, including myself. 回答1: It is quite simple using Java 2D. /** A method to determine if area1 is entirely contained within area2. */ public boolean doAreasEnclose(Area area1, Area area2) { Area temp = new Area(area1);