當前位置: 首頁>>代碼示例>>Java>>正文


Java ContactImpulse類代碼示例

本文整理匯總了Java中com.badlogic.gdx.physics.box2d.ContactImpulse的典型用法代碼示例。如果您正苦於以下問題:Java ContactImpulse類的具體用法?Java ContactImpulse怎麽用?Java ContactImpulse使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ContactImpulse類屬於com.badlogic.gdx.physics.box2d包,在下文中一共展示了ContactImpulse類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: play

import com.badlogic.gdx.physics.box2d.ContactImpulse; //導入依賴的package包/類
private Sound play(PhysixBodyComponent component, ContactImpulse impulse, Sound ignore) {
    if (component != null) {
        ImpactSoundComponent isc = ComponentMappers.impactSound.get(component.getEntity());
        if (isc != null && isc.sound != ignore && isc.lastPlayed.get() > isc.minDelay) {
            float impulseStrength = Math.abs(impulse.getNormalImpulses()[0]);
            if (impulseStrength > isc.minImpulseStrength) {
                float speed = component.getLinearVelocity().len();
                if (speed > isc.minSpeed) {
                    isc.lastPlayed.reset();
                    SoundEmitter.playGlobal(isc.sound, false, component.getX(), component.getY(), 0);
                    return isc.sound;
                }
            }
        }
    }
    return null;
}
 
開發者ID:GameDevWeek,項目名稱:CodeBase,代碼行數:18,代碼來源:ImpactSoundListener.java

示例2: onContact

import com.badlogic.gdx.physics.box2d.ContactImpulse; //導入依賴的package包/類
@Override
public void onContact(B2FlxShape sprite1, B2FlxShape sprite2, Contact contact, Manifold oldManifold, ContactImpulse impulse)
{
	if(_broke)
	{
		// The body already broke.
		return;
	}
	
	// Should the body break?
	int count = contact.getWorldManifold().getNumberOfContactPoints();
	
	float maxImpulse = 0.0f;
	for(int i = 0; i < count; i++)
	{
		maxImpulse = B2FlxMath.max(maxImpulse, impulse.getNormalImpulses()[i]);
	}
	
	if(maxImpulse > 40.0f)
	{
		_break = true;
	}
}
 
開發者ID:flixel-gdx,項目名稱:flixel-gdx-box2d,代碼行數:24,代碼來源:TestBreakable.java

示例3: postSolve

import com.badlogic.gdx.physics.box2d.ContactImpulse; //導入依賴的package包/類
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
    if(impulse.getNormalImpulses()[0] > 0.01)
    {
        /* If body A was hit */
        if(contact.getFixtureA() != null)
        {
            if (Actor.class.isInstance(contact.getFixtureA().getBody().getUserData())) {
                Actor a = (Actor) contact.getFixtureA().getBody().getUserData();
                evalDamage(a, impulse);

            }
        }

        /* If body B was hit */
        if(contact.getFixtureB() != null)
        {
            if (Actor.class.isInstance(contact.getFixtureB().getBody().getUserData())) {
                Actor b = (Actor) contact.getFixtureB().getBody().getUserData();
                evalDamage(b, impulse);
            }
        }
    }
}
 
開發者ID:OlliV,項目名稱:angr,代碼行數:25,代碼來源:ModelContactListener.java

示例4: evalDamage

import com.badlogic.gdx.physics.box2d.ContactImpulse; //導入依賴的package包/類
/**
 * Evaluate damage and score, and check if actor needs to be destroyed
 * @param actor Current actor
 * @param impulse Impulse
 */
private void evalDamage(Actor actor, ContactImpulse impulse) {
    if (Destructible.class.isInstance(actor)) {
        /* Hit and check final health status */
        if (((Destructible)actor).getDatamageModel() == null)
            return;
        ((Destructible)actor).getDatamageModel().hit(impulse.getNormalImpulses()[0]);
        if (((Destructible)actor).getDatamageModel().getHealth() < 0.01f) {

            if (!((Destructible)actor).isDestroyed()) {
                /* Update score counter */
                gameState.addPoints(((Destructible)actor).getDatamageModel().getPoints(),
                        ((Destructible)actor).getDatamageModel().isEnemy());

                /* Destroy actor */
                ((Destructible)actor).setDestroyed();
            }
        }
    }
}
 
開發者ID:OlliV,項目名稱:angr,代碼行數:25,代碼來源:ModelContactListener.java

示例5: postSolve

import com.badlogic.gdx.physics.box2d.ContactImpulse; //導入依賴的package包/類
/**
 * Called every time step while the fixtures are overlapping
 * Gives you a chance to find out what impulses were caused by the collision response after it has been applied
 *
 * @param contact
 * @param impulse
 */
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
    //Gdx.app.log(this.getClass().getSimpleName(), "postSolve() called");

    Body a = contact.getFixtureA().getBody();
    Body b = contact.getFixtureB().getBody();

    // If a is a player
    if (a.getUserData().getClass() == PlayerSystem.class) {
        // If b is a structure
        if (b.getUserData().getClass() == StructureSystem.class) {
            a.setUserData(BodyComponent.PLAYER_STRUCTURE_COLLISION);
        }
        // If b is an enemy
        if (b.getUserData().getClass() == EnemySystem.class) {
            a.setUserData(BodyComponent.PLAYER_ENEMY_COLLISION);
        }
    }

    // If b is a player
    if (b.getUserData().getClass() == PlayerSystem.class) {
        // If a is a structure
        if (a.getUserData().getClass() == StructureSystem.class) {
            b.setUserData(BodyComponent.PLAYER_STRUCTURE_COLLISION);
        }
        // If a is an enemy
        if (a.getUserData().getClass() == EnemySystem.class) {
            b.setUserData(BodyComponent.PLAYER_ENEMY_COLLISION);
        }
    }
}
 
開發者ID:DevelopersGuild,項目名稱:rebel-invader,代碼行數:39,代碼來源:PhysicsListener.java

示例6: postSolve

import com.badlogic.gdx.physics.box2d.ContactImpulse; //導入依賴的package包/類
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
	Fixture fixtureA = contact.getFixtureA();
	Fixture fixtureB = contact.getFixtureB();
	
	ContactListener listener = get(
		fixtureA.getFilterData().categoryBits,
		fixtureB.getFilterData().categoryBits
	);
	
	if (listener != null) {
		listener.postSolve(contact, impulse);
	}
}
 
開發者ID:saltares,項目名稱:libgdxjam,代碼行數:15,代碼來源:CollisionHandler.java

示例7: postSolve

import com.badlogic.gdx.physics.box2d.ContactImpulse; //導入依賴的package包/類
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
    Body bodyA = contact.getFixtureA().getBody(), bodyB = contact.getFixtureB().getBody();
    PhysicsComponent physA = (PhysicsComponent)bodyA.getUserData(), 
                     physB = (PhysicsComponent)bodyB.getUserData();
    if (physA == null || physB == null) return;
    physA.addCollisionNormal(impulse.getNormalImpulses()[0]);
    physB.addCollisionNormal(impulse.getNormalImpulses()[0]);
}
 
開發者ID:Deftwun,項目名稱:ZombieCopter,代碼行數:10,代碼來源:PhysicsSystem.java

示例8: postSolve

import com.badlogic.gdx.physics.box2d.ContactImpulse; //導入依賴的package包/類
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
	Fixture fixtureA = contact.getFixtureA();
	Fixture fixtureB = contact.getFixtureB();
	
	ContactListener listener = getListener(fixtureA.getFilterData().categoryBits,
										   fixtureB.getFilterData().categoryBits);
	
	if (listener != null) {
		listener.postSolve(contact, impulse);
	}
}
 
開發者ID:saltares,項目名稱:sioncore,代碼行數:13,代碼來源:CollisionHandler.java

示例9: postSolve

import com.badlogic.gdx.physics.box2d.ContactImpulse; //導入依賴的package包/類
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
    if (contact.getFixtureA() != null && contact.getFixtureB() != null) {
        for (ComponentContactListener listener : listenerMap.values()) {
            listener.postSolve(contact, impulse);
        }
    }
}
 
開發者ID:GameDevWeek,項目名稱:CodeBase,代碼行數:9,代碼來源:PhysixComponentAwareContactListener.java

示例10: onContact

import com.badlogic.gdx.physics.box2d.ContactImpulse; //導入依賴的package包/類
@Override
public void onContact(B2FlxShape sprite1, B2FlxShape sprite2, Contact contact, Manifold oldManifold, ContactImpulse impulse)
{
	_ghost2.removeOverlap();
	if(!_ghost2.gotOverlaps())
		_ghost2.setAlpha(1f);
}
 
開發者ID:flixel-gdx,項目名稱:flixel-gdx-box2d,代碼行數:8,代碼來源:TestCollisionDetection.java

示例11: postSolve

import com.badlogic.gdx.physics.box2d.ContactImpulse; //導入依賴的package包/類
/**
 * Internal: This lets you inspect a contact after the solver is finished. This is useful for inspecting impulses. Note: the contact
 * manifold does not include time of impact impulses, which can be arbitrarily large if the sub-step is small. Hence the
 * impulse is provided explicitly in a separate data structure. Note: this is only called for contacts that are touching,
 * solid, and awake.
 */
@Override
public void postSolve(Contact contact, ContactImpulse impulse)
{
	if(_event == null)
		return;
	_event.oldManifold = null;
	_event.impulse = impulse;
	dispatch(contact, B2FlxContactEvent.POST_SOLVE);
}
 
開發者ID:flixel-gdx,項目名稱:flixel-gdx-box2d,代碼行數:16,代碼來源:B2FlxContactListener.java

示例12: postSolve

import com.badlogic.gdx.physics.box2d.ContactImpulse; //導入依賴的package包/類
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
    AbstractWorldManager managerA=getManager(((Box2DPhysicsObject) contact.getFixtureA().getUserData()).getGrupo());
    AbstractWorldManager managerB=getManager(((Box2DPhysicsObject) contact.getFixtureB().getUserData()).getGrupo());

    if(managerA!=null) managerA.handlePostSolve(contact, impulse);
    if(managerB!=null) managerB.handlePostSolve(contact, impulse);

}
 
開發者ID:Rubentxu,項目名稱:DreamsLibGdx,代碼行數:10,代碼來源:WorldController.java

示例13: postSolve

import com.badlogic.gdx.physics.box2d.ContactImpulse; //導入依賴的package包/類
@Override public void postSolve(Contact arg0, ContactImpulse arg1) {
    // Not used.
}
 
開發者ID:StringMon,項目名稱:homescreenarcade,代碼行數:4,代碼來源:Field.java

示例14: postSolve

import com.badlogic.gdx.physics.box2d.ContactImpulse; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
}
 
開發者ID:AndreFCruz,項目名稱:feup-lpoo-armadillo,代碼行數:7,代碼來源:WorldContactListener.java

示例15: postSolve

import com.badlogic.gdx.physics.box2d.ContactImpulse; //導入依賴的package包/類
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
	// TODO Auto-generated method stub
	
}
 
開發者ID:jocasolo,項目名稱:water2d-libgdx,代碼行數:6,代碼來源:MyContactListener.java


注:本文中的com.badlogic.gdx.physics.box2d.ContactImpulse類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。