collision-detection

To use the JNI, or not to use the JNI (Android performance)

被刻印的时光 ゝ 提交于 2019-12-02 23:49:08
I just added some computationally expensive code to an Android game I am developing. The code in question is a collection of collision detection routines that get called very often (every iteration of the game-loop) and are doing a large amount of computation. I feel my collision detection implementation is fairly well developed, and as reasonably fast as I can make it in Java. I've been using Traceview to profile the code, and this new piece of collision detection code has somewhat unsurprisingly doubled the duration of my game logic. That's obviously a concern since for certain devices, this

jQuery spawning div and collision detection

孤人 提交于 2019-12-02 22:36:25
问题 So im almost at the end of my school homework project im just missing two major things i can't seem to figure out: 1.How to spawn the pipe obstacles with a random position for the gap so the bird can fly through (tought of using a function which changes the css 'right' attr of the pipe div for the gap position), and removing the pipe when it goes off screen bottom . (Its a inverted flappy bird game like btw..) 2.Second i need a help with the collision detection function so i know when game is

iOS - Drag and drop collision detection How to detect when your selected item drags over another subview?

梦想的初衷 提交于 2019-12-02 21:10:45
We are adding drag and drop functionality to what is to become a sports field with positions for players. The positions are mapped out using Interface Builder with each being a separate UIImageView. We want to be able to drag player images from bench positions from the side of the screen onto positions on the field. How best can we detect when the selected player which is being moved around collides with an existing gamePosition imageView? We are looking for a way to detect if there is a view or ImageView under the current location. -(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *

how to detect when a ImageView is in collision with another ImageView?

夙愿已清 提交于 2019-12-02 20:43:57
问题 Im developing a test game with some imageviews on the screen. with the finger, i am moving another imageview. I want to detect when the imageview moved by the finger has touched another imageview. ¿Wich is the best way to achieve it? I can't find info about it on google... Thanks 回答1: I'll answer the general question - find out when two views overlap : private boolean viewsOverlap(View v1, View v2) { int[] v1_coords = new int[2]; v1.getLocationOnScreen(v1_coords); int v1_w = v1.getWidth();

How to generate an end screen when two images collide?

為{幸葍}努か 提交于 2019-12-02 19:25:40
问题 how to generate an end screen when two images collide. I am making an app with a stickman you move with a very sensitive acceremeter. SO if it hits these spikes, (UIImages) it will generate the end screen. How do I make the app detect this collision and then generate an end screen. 回答1: I'm sure you know the rect of the two images because you need to draw them so you can use bool CGRectIntersectsRect ( CGRect rect1, CGRect rect2 ); It returns YES if the two rects have a shared point 回答2: The

Good 2D Collision Response References

血红的双手。 提交于 2019-12-02 17:39:28
Hey, I'm currently looking for various methods of implementing collision response in 2D video games, something similar to this tutorial Metanet has: N Tutorial I'm looking to implement something in XNA, but any language would be fine. I'm more interested in implementing programmatically than actual theory. I'd prefer more beginner friendly material, but I do welcome more advance topics. So could someone suggest some good 2D collision response articles/books? (PS: I'm more interested in response than detection) The N tutorial that you mentioned already is a great resource to start with. I also

problem with collision of two images

走远了吗. 提交于 2019-12-02 17:09:18
问题 Well here is my problem: I have two images : flakeImage and ViewToRotate. What I want is that if flakeImage touches ViewToRotate, ViewToRotate.alpha=0.5; but when FlakeImage appears on the screen ViewToRotate.alpha=0.5; without touching it. I think it's a problem with my view beacause I have : UIImageView* flakeView = [[UIImageView alloc] initWithImage:flakeImage]; here is the code : UIImageView* flakeView = [[UIImageView alloc] initWithImage:flakeImage]; // use the random() function to

Most efficient way to detect collision of two divs

故事扮演 提交于 2019-12-02 16:16:26
问题 I'm using Jquery Collision to detect two objects overlapping each other. Here is a JSFiddle of the problem. (apologies for including jquery collision script in HTML, couldn't find other way) Click anywhere in the gray container to move the green div over the white div. HTML Structure: <div class="container"> <div class="test"></div> <div class="menu"></div> </div> JS: $(document).ready(function () { var hit_list; $(".container").click(function () { $(".menu").stop().animate({ left: "+=100px"

IOS: verify if a point is inside a rect

为君一笑 提交于 2019-12-02 14:46:12
Is there a way to verify if a CGPoint is inside a specific CGRect . An example would be: I'm dragging a UIImageView and I want to verify if its central point CGPoint is inside another UIImageView Ole Begemann Swift 4 let view = ... let point = ... view.bounds.contains(point) Objective-C Use CGRectContainsPoint() : bool CGRectContainsPoint(CGRect rect, CGPoint point); Parameters rect The rectangle to examine. point The point to examine. Return Value true if the rectangle is not null or empty and the point is located within the rectangle; otherwise, false. A point is considered inside the

Slick2D Rectangle Collision Detection

淺唱寂寞╮ 提交于 2019-12-02 14:28:01
问题 I'm having an issue showing that one rectangle has collided with another. So my question is, how can I get the intersect method to check for collision? Or are there any other ways to handle collision in this situation? I'm creating a turn-based combat game (similar to Final Fantasy or Legend of Dragoon) where the player's character is on the right side of the screen and the enemy is on the left side. The player and enemy each take turns attacking. So when the player attacks, the sprite