game-physics

Collision detection between a BoundingBox and a Sphere in libgdx

南楼画角 提交于 2020-01-02 09:58:40
问题 In my libgdx game I have 3D BoundingBoxes and Spheres for map and player objects. I want to calculate whether they collide with each other in order to properly simulate the motion of these objects. What method can I use to calculate whether these objects collide/intersect? 回答1: You can use the following method: public static boolean intersectsWith(BoundingBox boundingBox, Sphere sphere) { float dmin = 0; Vector3 center = sphere.center; Vector3 bmin = boundingBox.getMin(); Vector3 bmax =

Java a moving animation (sprite)

拈花ヽ惹草 提交于 2020-01-02 08:48:50
问题 Hello i`ve got a problem: when i run this code i get this: on some java forum they said i need to add Graphics2DObject.clearRect(x1, y1, x2, y2); (where`s x1 and y1 is coordinates of the image and x2 y2 is width height of the image.) when i add it to the code i get this: The code(with added function): Main: import java.awt.*; import javax.swing.*; public class Main { public static void main(String []args){ Main b = new Main(); b.run(); } private Sprite sprite; private Animation a; private

Drag physic object in corona sdk

白昼怎懂夜的黑 提交于 2020-01-02 06:11:13
问题 I'm try to drag a dynamic body with gravity = 0,0 in my scene, I have a square with body type dynamic, and an image with body type static, but when drag the square over the image this have a little force but can exceed the image and pass to the other side like the images: This is my code to drag the square: local function dragBody( event ) local body = event.target local phase = event.phase local stage = display.getCurrentStage() if "began" == phase then stage:setFocus( body, event.id ) body

How to make a dynamic body static in Cocos2d v3.0 with Chipmunk

左心房为你撑大大i 提交于 2020-01-02 00:18:13
问题 I’m using Cocos2d v3 and want to change a body from dynamic to static after colliding with another body. At the moment I’ve got: -(void)ccPhysicsCollisionPostSolve:(CCPhysicsCollisionPair *)pair static:(CCNode *)nodeA wildcard:(CCNode *)nodeB { _player.physicsBody.type = CCPhysicsBodyTypeStatic; } or -(BOOL)ccPhysicsCollisionPreSolve:(CCPhysicsCollisionPair *)pair static:(CCNode *)nodeA wildcard:(CCNode *)nodeB { _player.physicsBody.type = CCPhysicsBodyTypeStatic; return YES; } but neither

Android, libgdx and box2d basics [closed]

痴心易碎 提交于 2020-01-01 08:38:30
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I wrote couple of simple board games since i started on android learning, Please let me know is there any tutorial or links, where i can start with physics library with libgdx, looking for something like basics

Android, libgdx and box2d basics [closed]

别说谁变了你拦得住时间么 提交于 2020-01-01 08:38:13
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I wrote couple of simple board games since i started on android learning, Please let me know is there any tutorial or links, where i can start with physics library with libgdx, looking for something like basics

Getting the velocity vector from position vectors

こ雲淡風輕ζ 提交于 2019-12-31 05:09:53
问题 I looked at a bunch of similar questions, and I cannot seem to find one that particularly answers my question. I am coding a simple 3d game, and I am trying to allow the player to pick up and move entities around my map. I essentially want to get a velocity vector that will "push" the physics object a distance from the player's eyes, wherever they are looking. Here's an example of this being done in another game (the player is holding a chair entity in front of his eyes). To do this, I find

Continuous movement with a single key press?

China☆狼群 提交于 2019-12-30 12:11:08
问题 I'm trying to make a program in java that involves making an object move constantly from a single key press. Think Pacman, where you press up once and Pacman continues to go up until you press another key. I want to keep the code simple if possible. My original movement (one keypress = one movement) is like this: public class AL extends KeyAdapter { public void keyPressed(KeyEvent e){ int keyCode = e.getKeyCode(); if(keyCode == e.VK_A){ x -= 5; } if(keyCode == e.VK_D){ x += 5; } if(keyCode ==

SpriteKit physics in Swift - Ball slides against wall instead of reflecting

南楼画角 提交于 2019-12-28 02:52:07
问题 I have been creating my own very simple test game based on Breakout while learning SpriteKit (using iOS Games by Tutorials by Ray Wenderlich et al.) to see if I can apply concepts that I have learned. I have decided to simplify my code by using an .sks file to create the sprite nodes and replacing my manual bounds checking and collision with physics bodies. However, my ball keeps running parallel to walls/other rectangles (as in, simply sliding up and down them) any time it collides with them

iOS 7 Sprite Kit freeing up memory

一个人想着一个人 提交于 2019-12-27 11:59:38
问题 I am building an iOS game aimed for the new iOS 7 and Sprite Kit, using emitter nodes and physics to enhance gameplay. While developing the app, I ran into a serious problem: you create your scenes, nodes, effects, but when you are done and need to return to the main screen, how do you free up all the memory allocated by these resources? Ideally ARC should free up everything and the application should get back to the memory consumption level it had before creating the scene, but this is not