本文整理汇总了C#中PloobsEngine.GetScaledTexture方法的典型用法代码示例。如果您正苦于以下问题:C# PloobsEngine.GetScaledTexture方法的具体用法?C# PloobsEngine.GetScaledTexture怎么用?C# PloobsEngine.GetScaledTexture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PloobsEngine
的用法示例。
在下文中一共展示了PloobsEngine.GetScaledTexture方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadContent
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
{
tile = factory.GetTexture2D("Textures/tile");
FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;
///border
border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red));
///from texture
{
Texture2D tex = factory.GetTexture2D("Textures//goo");
tex = factory.GetScaledTexture(tex, new Vector2(4));
IModelo2D model = new SpriteFarseer(tex);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model);
I2DObject o = new I2DObject(fs, mat, model);
o.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved);
this.World.AddObject(o);
}
///camera
this.World.Camera2D = new Camera2D(GraphicInfo);
///Create the Particle System
DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null));
this.World.ParticleManager.AddAndInitializeParticleSystem(ps);
///updateable
JointUpdateable ju = new JointUpdateable(this, fworld, this.World.Camera2D);
base.LoadContent(GraphicInfo, factory, contentManager);
}
示例2: LoadContent
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
{
tile = factory.GetTexture2D("Textures/tile");
FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;
///Ground
Vertices verts = PolygonTools.CreateRectangle(GraphicInfo.BackBufferWidth, 100);
{
IModelo2D model = new SpriteFarseer(factory, verts, Color.Red);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Static);
I2DObject o = new I2DObject(fs, mat, model);
///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
///We need to translate it a bit down
o.PhysicObject.Position = new Vector2(0, 250);
this.World.AddObject(o);
}
///animated sprite
{
///loading the texture
Texture2D tex = factory.GetTexture2D("Textures//DudeSheet");
///scale the texture (this is not good specially with animated texture, cause the whole texture is being scalled)
tex = factory.GetScaledTexture(tex, new Vector2(2));
///Loading the Sprite and extracting the frames
///8 = Maximum number of frames in the horizontal
///2 = Number of animation
///See the texture DudeSheet to undertand
SpriteAnimated sa = new SpriteAnimated(tex, 8, 2);
///Specify the first animation (First "line" of the texture) -- see the extra parameters in addAnimation
sa.AddAnimation("ANIM1", 1, 8, 0);
///Specify the Second animation (Second "line" of the texture)
sa.AddAnimation("ANIM2", 2, 4, 0);
///Create the Material
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
///To create the physic object, we extract one frame from the image and use it to be our physic body =P
Texture2D frame = factory.GetTexturePart(tex, sa.GetFrameRectangle("ANIM1", 0));
FarseerObject fs = new FarseerObject(fworld, frame);
sheet = new I2DObject(fs, mat, sa);
sheet.PhysicObject.Position = new Vector2(0,0);
this.World.AddObject(sheet);
}
///camera
this.World.Camera2D = new Camera2D(GraphicInfo);
base.LoadContent(GraphicInfo, factory, contentManager);
///when double tap, perform the following action
this.BindInput(new SimpleConcreteGestureInputPlayable(Microsoft.Xna.Framework.Input.Touch.GestureType.DoubleTap,
(a) =>
{
animationIndex = (animationIndex + 1) % 2;
(sheet.Modelo as SpriteAnimated).ChangeAnimation(animations[animationIndex]);
///you can play, pause, change ..... using the SpriteAnimated object.
}
));
}
示例3: LoadContent
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
{
tile = factory.GetTexture2D("Textures/tile");
FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;
///border
border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red));
///from texture, scale usage sample
{
Texture2D tex = factory.GetTexture2D("Textures//goo");
tex = factory.GetScaledTexture(tex, new Vector2(3));
IModelo2D model = new SpriteFarseer(tex);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, tex);
fs.Position = new Vector2(0, 50);
partobj = new I2DObject(fs, mat, model);
partobj.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved);
this.World.AddObject(partobj);
}
Vertices verts = PolygonTools.CreateRectangle(150, 150);
{
IModelo2D model = new SpriteFarseer(factory, verts, Color.Green);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Dynamic);
I2DObject o = new I2DObject(fs, mat, model);
///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
///We need to translate it a bit down
o.PhysicObject.Position = new Vector2(100, 100);
this.World.AddObject(o);
}
//circle
verts = PolygonTools.CreateCircle(150, 150);
{
IModelo2D model = new SpriteFarseer(factory, verts, Color.Orange);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Dynamic);
I2DObject o = new I2DObject(fs, mat, model);
o.PhysicObject.Position = new Vector2(-100, -100);
this.World.AddObject(o);
}
///camera
this.World.Camera2D = new Camera2D(GraphicInfo);
DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null));
this.World.ParticleManager.AddAndInitializeParticleSystem(ps);
///updateable
ju = new JointUpdateable(this, fworld, this.World.Camera2D);
base.LoadContent(GraphicInfo, factory, contentManager);
}
示例4: LoadContent
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
{
tile = factory.GetTexture2D("Textures/tile");
FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;
///border
border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red));
///from texture
{
Texture2D tex = factory.GetTexture2D("Textures//goo");
IModelo2D model = new SpriteFarseer(tex);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model);
I2DObject o = new I2DObject(fs, mat, model);
o.PhysicObject.Position = new Vector2(200, 0);
this.World.AddObject(o);
}
///from texture, scale usage sample
{
Texture2D tex = factory.GetTexture2D("Textures//goo");
tex = factory.GetScaledTexture(tex, new Vector2(2));
IModelo2D model = new SpriteFarseer(tex);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model);
I2DObject o = new I2DObject(fs, mat, model);
o.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved);
this.World.AddObject(o);
}
///rectangle
Vertices verts = PolygonTools.CreateRectangle(50, 50);
{
IModelo2D model = new SpriteFarseer(factory, verts, Color.Orange);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model);
I2DObject o = new I2DObject(fs, mat, model);
o.PhysicObject.Position = new Vector2(-200, 0);
this.World.AddObject(o);
}
///circle
CircleShape circle = new CircleShape(50, 1);
{
IModelo2D model = new SpriteFarseer(factory, circle, Color.Orange);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model);
I2DObject o = new I2DObject(fs, mat, model);
o.PhysicObject.Position = new Vector2(200, -100);
this.World.AddObject(o);
}
///animated sprite
{
Texture2D tex = factory.GetTexture2D("Textures//DudeSheet");
SpriteAnimated sa = new SpriteAnimated(tex, 8, 2);
sa.AddAnimation("ANIM1", 1, 8, 0);
sa.AddAnimation("ANIM2", 2, 4, MathHelper.PiOver2);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
Texture2D frame = factory.GetTexturePart(tex, sa.GetFrameRectangle("ANIM1", 0));
FarseerObject fs = new FarseerObject(fworld, frame);
//GhostObject fs = new GhostObject(Vector2.Zero);
sheet = new I2DObject(fs, mat, sa);
sheet.PhysicObject.Position = new Vector2(500, 0);
this.World.AddObject(sheet);
}
{
PointLight2D l = new PointLight2D(new Vector2(-GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Red, 1);
this.World.AddLight(l);
}
{
SpotLight2D l = new SpotLight2D(new Vector2(+GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Blue, new Vector2(0, 1), MathHelper.ToRadians(45));
this.World.AddLight(l);
}
{
SimpleConcreteKeyboardInputPlayable sc = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Space);
sc.KeyStateChange += new KeyStateChange(sc_KeyStateChange);
this.BindInput(sc);
}
///camera
this.World.Camera2D = new Camera2D(GraphicInfo);
DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null));
this.World.ParticleManager.AddAndInitializeParticleSystem(ps);
///add a post effect =P
//this.RenderTechnic.AddPostEffect(new WigglePostEffect());
///updateable
JointUpdateable ju = new JointUpdateable(this, fworld, this.World.Camera2D);
base.LoadContent(GraphicInfo, factory, contentManager);
//.........这里部分代码省略.........
示例5: LoadContent
//.........这里部分代码省略.........
///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
///We need to translate it a bit down
o.PhysicObject.Position = new Vector2(GraphicInfo.BackBufferWidth * 2, 250);
this.World.AddObject(o);
}
///Support
verts = PolygonTools.CreateRectangle(50, 200);
{
IModelo2D model = new SpriteFarseer(factory, verts, Color.Yellow);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Static);
I2DObject o = new I2DObject(fs, mat, model);
///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
///We need to translate it a bit down
o.PhysicObject.Position = new Vector2(0, 100);
this.World.AddObject(o);
}
///plataform 1
verts = PolygonTools.CreateRectangle(50, 200);
{
IModelo2D model = new SpriteFarseer(factory, verts, Color.Green);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Dynamic);
I2DObject o = new I2DObject(fs, mat, model);
///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
///We need to translate it a bit down
o.PhysicObject.Position = new Vector2(GraphicInfo.BackBufferWidth * 1.5f, 100);
this.World.AddObject(o);
}
///plataform 2
verts = PolygonTools.CreateRectangle(50, 200);
{
IModelo2D model = new SpriteFarseer(factory, verts, Color.Green);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Dynamic);
I2DObject o = new I2DObject(fs, mat, model);
///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
///We need to translate it a bit down
o.PhysicObject.Position = new Vector2(GraphicInfo.BackBufferWidth * 1.6f, 100);
this.World.AddObject(o);
}
///plataform 3
verts = PolygonTools.CreateRectangle(200, 50);
{
IModelo2D model = new SpriteFarseer(factory, verts, Color.Green);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Dynamic);
I2DObject o = new I2DObject(fs, mat, model);
///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
///We need to translate it a bit down
o.PhysicObject.Position = new Vector2(GraphicInfo.BackBufferWidth * 1.55f, -100);
this.World.AddObject(o);
}
///objective
{
Texture2D tex = factory.GetTexture2D("Textures//goo");
tex = factory.GetScaledTexture(tex,new Vector2(2));
IModelo2D model = new SpriteFarseer(tex);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model);
goo = new I2DObject(fs, mat, model);
goo.PhysicObject.Position = new Vector2(GraphicInfo.BackBufferWidth * 1.55f, -175);
this.World.AddObject(goo);
}
///Ball
CircleShape circle = new CircleShape(50, 1);
{
IModelo2D model = new SpriteFarseer(factory, circle, Color.Orange);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model);
ball = new I2DObject(fs, mat, model);
ball.PhysicObject.Position = new Vector2(0, -25);
ball.OnUpdate += new PloobsEngine.SceneControl._2DScene.OnUpdate(ball_OnUpdate);
this.World.AddObject(ball);
}
///the basic ortographic 2D camera
Camera2D Camera2D = new Camera2D(GraphicInfo);
Camera2D.Position = new Vector2(GraphicInfo.BackBufferWidth * 1.6f, 0);
///teleport to the given position
Camera2D.Jump2Target();
this.World.Camera2D = Camera2D;
///go to the desired position but without teleport =P
Camera2D.IntertiaController = 0.09f;
Camera2D.Position = new Vector2(0, 0);
Camera2D.EnablePositionTracking = true;
Camera2D.ReachedTheTrackingPosition += new Action<PloobsEngine.SceneControl._2DScene.Camera2D>(Camera2D_ReachedTheTrackingPosition);
base.LoadContent(GraphicInfo, factory, contentManager);
}
示例6: LoadContent
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
{
tile = factory.GetTexture2D("Textures/tile");
FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;
///border
border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red));
///from texture
{
Texture2D tex = factory.GetTexture2D("Textures//goo");
IModelo2D model = new SpriteFarseer(tex);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, tex);
I2DObject o = new I2DObject(fs, mat, model);
o.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved);
this.World.AddObject(o);
}
///from texture, scale usage sample
{
Texture2D tex = factory.GetTexture2D("Textures//goo");
tex = factory.GetScaledTexture(tex, new Vector2(2));
IModelo2D model = new SpriteFarseer(tex);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, tex);
I2DObject o = new I2DObject(fs, mat, model);
this.World.AddObject(o);
}
///rectangle
Vertices verts = PolygonTools.CreateRectangle(5, 5);
{
IModelo2D model = new SpriteFarseer(factory, verts, Color.Orange);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, verts);
I2DObject o = new I2DObject(fs, mat, model);
this.World.AddObject(o);
}
///circle
CircleShape circle = new CircleShape(5, 1);
{
IModelo2D model = new SpriteFarseer(factory, circle, Color.Orange);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, circle);
I2DObject o = new I2DObject(fs, mat, model);
this.World.AddObject(o);
}
///camera
this.World.Camera2D = new Camera2D(GraphicInfo);
DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null));
this.World.ParticleManager.AddAndInitializeParticleSystem(ps);
///add a post effect =P
//this.RenderTechnic.AddPostEffect(new WigglePostEffect());
///updateable
JointUpdateable ju = new JointUpdateable(this, fworld, this.World.Camera2D);
base.LoadContent(GraphicInfo, factory, contentManager);
}
示例7: LoadContent
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
{
tile = factory.GetTexture2D("Textures/tile");
FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;
///border
border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red));
///from texture
{
Texture2D tex = factory.GetTexture2D("Textures//goo");
IModelo2D model = new SpriteFarseer(tex);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model);
I2DObject o = new I2DObject(fs, mat, model);
o.PhysicObject.Position = new Vector2(200, 0);
this.World.AddObject(o);
}
///from texture, scale usage sample
{
Texture2D tex = factory.GetTexture2D("Textures//goo");
tex = factory.GetScaledTexture(tex, new Vector2(2));
IModelo2D model = new SpriteFarseer(tex);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model);
I2DObject o = new I2DObject(fs, mat, model);
o.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved);
this.World.AddObject(o);
}
///rectangle
Vertices verts = PolygonTools.CreateRectangle(50, 50);
{
IModelo2D model = new SpriteFarseer(factory, verts, Color.Orange);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model);
I2DObject o = new I2DObject(fs, mat, model);
o.PhysicObject.Position = new Vector2(-200, 0);
this.World.AddObject(o);
}
///circle
CircleShape circle = new CircleShape(50, 1);
{
IModelo2D model = new SpriteFarseer(factory, circle , Color.Orange);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model);
I2DObject o = new I2DObject(fs, mat, model);
o.PhysicObject.Position = new Vector2(200, -100);
this.World.AddObject(o);
}
///animated sprite
{
Texture2D tex = factory.GetTexture2D("Textures//DudeSheet");
SpriteAnimated sa = new SpriteAnimated(tex, 8, 2);
sa.AddAnimation("ANIM1", 1, 8,0);
sa.AddAnimation("ANIM2", 2, 4, MathHelper.PiOver2);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
Texture2D frame = factory.GetTexturePart(tex,sa.GetFrameRectangle("ANIM1",0));
FarseerObject fs = new FarseerObject(fworld, frame);
//GhostObject fs = new GhostObject(Vector2.Zero);
sheet = new I2DObject(fs, mat, sa);
sheet.PhysicObject.Position = new Vector2(500, 0);
this.World.AddObject(sheet);
}
{
PointLight2D l = new PointLight2D(new Vector2(-GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Red, 1);
this.World.AddLight(l);
}
{
SpotLight2D l = new SpotLight2D(new Vector2(+GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Blue, new Vector2(0, 1), MathHelper.ToRadians(45));
this.World.AddLight(l);
}
{
SimpleConcreteKeyboardInputPlayable sc = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS,Keys.Space);
sc.KeyStateChange+=new KeyStateChange(sc_KeyStateChange);
this.BindInput(sc);
}
///camera
this.World.Camera2D = new Camera2D(GraphicInfo);
DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null));
this.World.ParticleManager.AddAndInitializeParticleSystem(ps);
///add a post effect =P
//this.RenderTechnic.AddPostEffect(new WigglePostEffect());
///updateable
JointUpdateable ju = new JointUpdateable(this, fworld, this.World.Camera2D);
base.LoadContent(GraphicInfo, factory, contentManager);
//.........这里部分代码省略.........
示例8: LoadContent
//.........这里部分代码省略.........
///target 1
verts = PolygonTools.CreateRectangle(50, 200);
{
IModelo2D model = new SpriteFarseer(factory, verts, Color.Green);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Dynamic);
I2DObject o = new I2DObject(fs, mat, model);
///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
///We need to translate it a bit down
o.PhysicObject.Position = new Vector2(GraphicInfo.BackBufferWidth * 1.5f, 100);
this.World.AddObject(o);
}
///target 2
verts = PolygonTools.CreateRectangle(50, 200);
{
IModelo2D model = new SpriteFarseer(factory, verts, Color.Green);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Dynamic);
I2DObject o = new I2DObject(fs, mat, model);
///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
///We need to translate it a bit down
o.PhysicObject.Position = new Vector2(GraphicInfo.BackBufferWidth * 1.6f, 100);
this.World.AddObject(o);
}
///target 3
verts = PolygonTools.CreateRectangle(200, 50);
{
IModelo2D model = new SpriteFarseer(factory, verts, Color.Green);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Dynamic);
I2DObject o = new I2DObject(fs, mat, model);
///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
///We need to translate it a bit down
o.PhysicObject.Position = new Vector2(GraphicInfo.BackBufferWidth * 1.55f, -100);
this.World.AddObject(o);
}
///objective
///from texture
{
Texture2D tex = factory.GetTexture2D("Textures//goo");
tex = factory.GetScaledTexture(tex,new Vector2(2));
IModelo2D model = new SpriteFarseer(tex);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model);
goo = new I2DObject(fs, mat, model);
goo.PhysicObject.Position = new Vector2(GraphicInfo.BackBufferWidth * 1.55f, -175);
this.World.AddObject(goo);
}
///Ball
CircleShape circle = new CircleShape(50, 1);
{
IModelo2D model = new SpriteFarseer(factory, circle, Color.Orange);
Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
FarseerObject fs = new FarseerObject(fworld, model);
ball = new I2DObject(fs, mat, model);
ball.PhysicObject.Position = new Vector2(0, -25);
ball.OnUpdate += new PloobsEngine.SceneControl._2DScene.OnUpdate(ball_OnUpdate);
this.World.AddObject(ball);
}
SimpleConcreteMouseBottomInputPlayable SimpleConcreteMouseBottomInputPlayable1 = new SimpleConcreteMouseBottomInputPlayable(StateKey.PRESS, EntityType.TOOLS, PloobsEngine.Input.MouseButtons.LeftButton,
(sample) =>
{
mousepressed = true;
}
);
this.BindInput(SimpleConcreteMouseBottomInputPlayable1);
SimpleConcreteMouseBottomInputPlayable SimpleConcreteMouseBottomInputPlayable = null;
SimpleConcreteMouseBottomInputPlayable = new SimpleConcreteMouseBottomInputPlayable(StateKey.RELEASE, EntityType.TOOLS, PloobsEngine.Input.MouseButtons.LeftButton,
(sample) =>
{
mousepressed = false;
lines.isEnabled = false;
fired = true;
Vector2 mpos = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);
Vector2 wpos = this.World.Camera2D.ConvertScreenToWorld(mpos);
Vector2 force = (ball.PhysicObject.Position - wpos) * 30;
ball.PhysicObject.ApplyForce(force);
this.RemoveInputBinding(SimpleConcreteMouseBottomInputPlayable);
this.RemoveInputBinding(SimpleConcreteMouseBottomInputPlayable1);
(this.World.Camera2D as Camera2D).TrackingBody = ball;
}
);
this.BindInput(SimpleConcreteMouseBottomInputPlayable);
///the basic ortographic 2D camera
this.World.Camera2D = new Camera2D(GraphicInfo);
base.LoadContent(GraphicInfo, factory, contentManager);
Primitive2DDraw.Add2DPrimitive(lines);
}