当前位置: 首页>>代码示例>>Java>>正文


Java PointState类代码示例

本文整理汇总了Java中org.jbox2d.collision.Collision.PointState的典型用法代码示例。如果您正苦于以下问题:Java PointState类的具体用法?Java PointState怎么用?Java PointState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PointState类属于org.jbox2d.collision.Collision包,在下文中一共展示了PointState类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: preSolve

import org.jbox2d.collision.Collision.PointState; //导入依赖的package包/类
public void preSolve(Contact contact, Manifold oldManifold) {
	//do not change world inside here (add/remove objects)
	
	StaticGameObject obja =(StaticGameObject)contact.m_fixtureA.m_body.m_userData;
	StaticGameObject objb =(StaticGameObject)contact.m_fixtureB.m_body.m_userData;
	
	//whether we must handle this impact, even if it was not newly added
	//in this step. setting handle_impact always to true would not cause
	//problems but would only lead to increased network traffic
	boolean handle_impact = false;
	
	if(obja.type == Type.Hole || objb.type == Type.Hole) {
		GamePlayer player = null;
		Fixture player_fixture = null;
		if(obja.type == Type.Player) {
			player = (GamePlayer) obja;
			player_fixture = contact.m_fixtureA;
		} else if(objb.type == Type.Player) {
			player = (GamePlayer) objb;
			player_fixture = contact.m_fixtureB;
		}
		if(player == null || player.m_item_type != ItemType.DontFall) {
			contact.setEnabled(false);
			if(player_fixture != null && player_fixture.m_userData != null) {
				//at this point we must handle the impact even if this conact
				//was not newly added. because the player had the DontFall
				//item, but not anymore.
				handle_impact = true;
				player_fixture.m_userData = null;
			}
		} else {
			//we have a player with the DontFall item: we need a flag to
			//remember this: simply use m_userData and set it to !=null
			player_fixture.m_userData = player_fixture;
		}
	} else if(obja.type == Type.Item || objb.type == Type.Item) {
		contact.setEnabled(false);
	}
	
	contact.getWorldManifold(m_tmp_world_manifold);
	Collision.getPointStates(m_tmp_state1, m_tmp_state2, oldManifold, contact.m_manifold);
	if (m_tmp_state2[0] == PointState.ADD_STATE || handle_impact) {
		
		if(m_impact_count >= m_impacts.length) { //need to resize
			Impact[] new_impacts = new Impact[m_impacts.length*2];
			for(int i=0; i<new_impacts.length; ++i) 
				new_impacts[i] = new Impact();
			for(int i=0; i<m_impact_count; ++i)
				m_impacts[i].copyTo(new_impacts[i]);
			m_impacts = new_impacts;
		}

		Vec2 impact_point = m_tmp_world_manifold.points[0];
		Vec2 normal = m_tmp_world_manifold.normal;
		
		m_impacts[m_impact_count].obja =(StaticGameObject)contact.m_fixtureA.m_body.m_userData;
		m_impacts[m_impact_count].objb =(StaticGameObject)contact.m_fixtureB.m_body.m_userData;
		m_impacts[m_impact_count].impact_point.set(impact_point.x, impact_point.y);
		m_impacts[m_impact_count].normal.set(normal.x, normal.y);
		++m_impact_count;
		
	}
}
 
开发者ID:bkueng,项目名称:clash_of_balls,代码行数:64,代码来源:GameBase.java


注:本文中的org.jbox2d.collision.Collision.PointState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。