本文整理汇总了C#中Box2D.Dynamics.b2World类的典型用法代码示例。如果您正苦于以下问题:C# b2World类的具体用法?C# b2World怎么用?C# b2World使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
b2World类属于Box2D.Dynamics命名空间,在下文中一共展示了b2World类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Enemy
public Enemy(b2World world,
CCPoint location,
string spriteFileName,
bool isTheRotationFixed,
bool getsDamageFromGround,
bool doesGetDamageFromDamageEnabledStackObjects,
int breaksFromHowMuchContact,
bool hasDifferentSpritesForDamage,
int numberOfFramesToAnimateOnBreak,
float density,
CreationMethod createHow,
int points,
BreakEffect simpleScoreVisualFXType )
{
InitWithWorld( world,
location,
spriteFileName,
isTheRotationFixed,
getsDamageFromGround,
doesGetDamageFromDamageEnabledStackObjects,
breaksFromHowMuchContact,
hasDifferentSpritesForDamage,
numberOfFramesToAnimateOnBreak,
density,
createHow,
points,
simpleScoreVisualFXType );
}
示例2: InitStackWithWorld
void InitStackWithWorld(b2World theWorld)
{
this.world = theWorld;
if (TheLevel.SharedLevel.IS_IPAD)
{
stackLocationX = 1400; //base X starting point for the entire stack on the iPad (make further tweaks using the stackAdjustmentX var in the buildLevel function per level
stackLocationY = 100; //base Y starting point for the entire stack on the iPad (make further tweaks using the stackAdjustmentY var in the buildLevel function per level
}
else
{
stackLocationX = 900; //base X starting point for the entire stack on the iPhone (make further tweaks using the stackAdjustmentX var in the buildLevel function per level
stackLocationY = 35; //base Y starting point for the entire stack on the iPhone (make further tweaks using the stackAdjustmentY var in the buildLevel function per level
}
currentLevel = GameData.SharedData.Level;
if (currentLevel % 2 == 0)
{
BuildLevel2();
}
else
{
BuildLevel1();
}
}
示例3: InitPhysics
void InitPhysics()
{
var gravity = new b2Vec2(0.0f, -10.0f);
world = new b2World(gravity);
world.SetAllowSleeping(true);
world.SetContinuousPhysics(true);
var def = new b2BodyDef();
def.allowSleep = true;
def.position = b2Vec2.Zero;
def.type = b2BodyType.b2_staticBody;
b2Body groundBody = world.CreateBody(def);
groundBody.SetActive(true);
b2EdgeShape groundBox = new b2EdgeShape();
groundBox.Set(b2Vec2.Zero, new b2Vec2(900, 100));
b2FixtureDef fd = new b2FixtureDef();
fd.friction = 0.3f;
fd.restitution = 0.1f;
fd.shape = groundBox;
groundBody.CreateFixture(fd);
}
示例4: MouseTouch
public MouseTouch(b2World world, RubeBasicLayer layer)
{
parent = layer;
m_world = world;
b2BodyDef bodyDef = new b2BodyDef();
m_groundBody = m_world.CreateBody(bodyDef);
}
示例5: JumpPad
public JumpPad(b2Vec2 JumpImpuls, CCPoint Position, b2World gameWorld)
{
this.Texture = new CCTexture2D ("jumppad");
this.Scale = SpriteScale;
this.Position = Position;
this.IsAntialiased = false;
jumpImpuls = JumpImpuls;
totalJumps = 0;
//box2d
b2BodyDef jumpPadDef = new b2BodyDef ();
jumpPadDef.type = b2BodyType.b2_kinematicBody;
jumpPadDef.position = new b2Vec2 ((Position.X + this.ScaledContentSize.Width/2)/PhysicsHandler.pixelPerMeter, (Position.Y + this.ScaledContentSize.Height/4) / PhysicsHandler.pixelPerMeter);
JumpPadBody = gameWorld.CreateBody (jumpPadDef);
b2PolygonShape jumpPadShape = new b2PolygonShape ();
jumpPadShape.SetAsBox ((float)this.ScaledContentSize.Width / PhysicsHandler.pixelPerMeter / 2, (float)this.ScaledContentSize.Height / PhysicsHandler.pixelPerMeter / 4);// /4 weil die hitbox nur die hälfte der textur ist
b2FixtureDef jumpPadFixture = new b2FixtureDef ();
jumpPadFixture.shape = jumpPadShape;
jumpPadFixture.density = 0.0f; //Dichte
jumpPadFixture.restitution = 0f; //Rückprall
jumpPadFixture.friction = 0f;
jumpPadFixture.userData = WorldFixtureData.jumppad;
JumpPadBody.CreateFixture (jumpPadFixture);
//
}
示例6: InitWithWorld
private void InitWithWorld( b2World world, CCPoint location, string spriteFileName)
{
this.theWorld = world;
this.initialLocation = location;
this.spriteImageName = spriteFileName;
CreateGround();
}
示例7: StackObject
public BreakEffect SimpleScoreVisualFX { get; set; } //defined in Constants.cs
public StackObject (b2World world,
CCPoint location,
string spriteFileName,
bool breaksOnGround,
bool breaksFromNinja,
bool hasAnimatedBreakFrames,
bool damagesEnemy,
float density,
CreationMethod createHow,
int angleChange,
bool makeImmovable,
int points,
BreakEffect simpleScoreVisualFXType)
{
InitWithWorld(world,
location,
spriteFileName,
breaksOnGround,
breaksFromNinja,
hasAnimatedBreakFrames,
damagesEnemy,
density,
createHow,
angleChange,
makeImmovable,
points,
simpleScoreVisualFXType);
}
示例8: InitWithWorld
void InitWithWorld(b2World world,
CCPoint location,
string spriteFileName,
bool isTheRotationFixed,
bool getsDamageFromGround,
bool doesGetDamageFromDamageEnabledStackObjects,
int breaksFromHowMuchContact,
bool hasDifferentSpritesForDamage,
int numberOfFramesToAnimateOnBreak,
float density,
CreationMethod createHow,
int points,
BreakEffect simpleScoreVisualFXType)
{
this.theWorld = world;
this.initialLocation = location;
this.baseImageName = spriteFileName;
this.spriteImageName = String.Format("{0}", baseImageName);
this.DamagesFromGroundContact = getsDamageFromGround; // does the ground break / damage the enemy
this.damageLevel = 0; //starts at 0, if breaksAfterHowMuchContact also equals 0 then the enemy will break on first/next contact
this.breaksAfterHowMuchContact = breaksFromHowMuchContact; //contact must be made this many times before breaking, or if set to 0, the enemy will break on first/next contact
this.differentSpritesForDamage = hasDifferentSpritesForDamage; //will progress through damage frames if this is YES, for example, enemy_damage1.png, enemy_damage2.png
this.currentFrame = 0;
this.framesToAnimateOnBreak = numberOfFramesToAnimateOnBreak; //will animate through breaks frames if this is more than 0, for example, enemy_break0001.png, enemy_break0002.png
this.theDensity = density;
this.shapeCreationMethod = createHow;
this.isRotationFixed = isTheRotationFixed;
this.PointValue = points;
this.SimpleScoreVisualFX = simpleScoreVisualFXType;
this.DamagesFromDamageEnabledStackObjects = doesGetDamageFromDamageEnabledStackObjects;
if (damageLevel == breaksAfterHowMuchContact)
{
BreaksOnNextDamage = true;
}
else
{
BreaksOnNextDamage = false; //duh
}
CreateEnemy();
}
示例9: InitWithWorld
private void InitWithWorld (b2World world, CCPoint location, string baseFileName)
{
theWorld = world;
initialLocation = location;
baseImageName = baseFileName;
//later we use initialLocation.x
CreateNinja();
}
示例10: CreateBodyWithSpriteAndFixture
protected void CreateBodyWithSpriteAndFixture(b2World world, b2BodyDef bodyDef,
b2FixtureDef fixtureDef, string spriteName)
{
// this is the meat of our class, it creates (OR recreates) the body in the world with the body definition, fixture definition and sprite name
RemoveBody(); //if remove the body if it already exists
RemoveSprite(); //if remove the sprite if it already exists
sprite = new CCSprite(spriteName);
AddChild(sprite);
body = world.CreateBody(bodyDef);
body.UserData = this;
if (fixtureDef != null)
body.CreateFixture(fixtureDef);
}
示例11: GameScene
public GameScene(Game game)
{
this.game = game;
// ��ʼ��world
b2Vec2 gravity = new b2Vec2(0f, -20f);
world = new b2World(gravity);
world.AllowSleep = false;
InitBack();
AddBarLayer();
InitScore();
AddGround();
AddBird();
world.SetContactListener(new BirdContactListener(this, (CCSprite)(birdBody.UserData)));
this.schedule(tick);
SimpleAudioEngine.sharedEngine().playBackgroundMusic(@"musics/background", true);
}
示例12: Initialize
public void Initialize(float mapSizeWidth, Character Character, CCTileMapLayer physicsLayer, CCTileMap physicsMap, Container gameContainer)
{
mapSizeWidth /= pixelPerMeter;
gameWorld = new b2World (new b2Vec2 (0, -9.8f));
gameWorld.AllowSleep = false;
//definiert den MainCharacter
Character.createPhysicsBody (gameWorld);
defineGround (mapSizeWidth);
createBox2DWorldByLayer (physicsLayer, physicsMap);
debugDrawer = new DebugDraw ();
gameWorld.SetDebugDraw (debugDrawer);
debugDrawer.AppendFlags (b2DrawFlags.e_shapeBit);
collusionSensor = new CollusionSensor (gameContainer);
gameWorld.SetContactListener (collusionSensor);
}
示例13: Mouse
public Mouse()
{
//m_destructionListener = new DestructionListener();
m_debugDraw = new CCBox2dDraw("fonts/arial-16");
b2Vec2 gravity = new b2Vec2();
gravity.Set(500, 500);
m_world = new b2World(gravity);
m_world.SetAllowSleeping(false);
m_world.SetContinuousPhysics(true);
m_world.SetDebugDraw(m_debugDraw);
m_debugDraw.AppendFlags(b2DrawFlags.e_shapeBit | b2DrawFlags.e_aabbBit | b2DrawFlags.e_centerOfMassBit | b2DrawFlags.e_jointBit | b2DrawFlags.e_pairBit);
m_world.SetContinuousPhysics(true);
m_world.SetWarmStarting(true);
}
示例14: BoxProp
public BoxProp(
b2World b2world,
double[] size,
double[] position
)
{
/*
static rectangle shaped prop
pars:
size - array [width, height]
position - array [x, y], in world meters, of center
*/
this.size = size;
//initialize body
var bdef = new b2BodyDef();
bdef.position = new b2Vec2(position[0], position[1]);
bdef.angle = 0;
bdef.fixedRotation = true;
this.body = b2world.CreateBody(bdef);
//initialize shape
var fixdef = new b2FixtureDef();
var shape = new b2PolygonShape();
fixdef.shape = shape;
shape.SetAsBox(this.size[0] / 2, this.size[1] / 2);
fixdef.restitution = 0.4; //positively bouncy!
this.body.CreateFixture(fixdef);
}
示例15: InitWithWorld
void InitWithWorld(b2World world,
CCPoint location,
string spriteFileName,
bool breaksOnGround,
bool breaksFromNinja,
bool hasAnimatedBreakFrames,
bool damagesEnemy,
float density,
CreationMethod createHow,
int angleChange,
bool makeImmovable,
int points,
BreakEffect simpleScoreVisualFXType)
{
this.theWorld = world;
this.initialLocation = location;
this.baseImageName = spriteFileName;
this.spriteImageName = String.Format("{0}", baseImageName);
this.IsBreaksOnGroundContact = breaksOnGround;
this.IsBreaksOnNinjaContact = breaksFromNinja;
this.addedAnimatedBreakFrames = hasAnimatedBreakFrames;
this.IsCanDamageEnemy = damagesEnemy;
this.theDensity = density;
this.shapeCreationMethod = createHow;
this.angle = angleChange;
this.IsStatic = makeImmovable;
this.currentFrame = 0;
this.framesToAnimate = 10;
this.PointValue = points ;
this.SimpleScoreVisualFX = simpleScoreVisualFXType;
CreateObject();
}