本文整理汇总了C#中Loon.Core.Geom.RectBox类的典型用法代码示例。如果您正苦于以下问题:C# RectBox类的具体用法?C# RectBox怎么用?C# RectBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RectBox类属于Loon.Core.Geom命名空间,在下文中一共展示了RectBox类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Intersect
/// <summary>
/// �ж�ָ����С�����������Ƿ��ཻ
/// </summary>
///
/// <param name="rectA"></param>
/// <param name="dataA"></param>
/// <param name="rectB"></param>
/// <param name="dataB"></param>
/// <returns></returns>
public static bool Intersect(RectBox rectA, int[] dataA, RectBox rectB,
int[] dataB)
{
int top = (int)Loon.Utils.MathUtils.Max(rectA.GetY(), rectB.GetY());
int bottom = (int)Loon.Utils.MathUtils.Min(rectA.GetBottom(), rectB.GetBottom());
int left = (int)Loon.Utils.MathUtils.Max(rectA.GetX(), rectB.GetX());
int right = (int)Loon.Utils.MathUtils.Min(rectA.GetRight(), rectB.GetRight());
for (int y = top; y < bottom; y++)
{
for (int x = left; x < right; x++)
{
int colorA = dataA[(int)((x - rectA.x) + (y - rectA.y)
* rectA.width)];
int colorB = dataB[(int)((x - rectB.x) + (y - rectB.y)
* rectB.width)];
if ((int)(((uint)colorA) >> 24) != 0 && (int)(((uint)colorB) >> 24) != 0)
{
return true;
}
}
}
return false;
}
开发者ID:ordanielcmessias,项目名称:LGame,代码行数:35,代码来源:CollisionHelper.cs
示例2: LObjectCamera
public LObjectCamera(RectBox r, object f, int width, int height,
int horBorderPixel_0, int vertBorderPixel_1, Vector2f maxSpeed_2)
{
this.cameraX = 0;
this.cameraY = 0;
this.renderWidth = width;
this.renderHeight = height;
this.follow = new Bind(f);
this.horBorderPixel = horBorderPixel_0;
this.vertBorderPixel = vertBorderPixel_1;
this.maxSpeed = maxSpeed_2;
if (follow != null)
{
this.cameraX = follow.GetX() - (this.renderWidth / 2);
this.cameraY = follow.GetY() - (this.renderHeight / 2);
}
this.cameraRect = r;
this.visibleRect = new RectBox(cameraX - horBorderPixel_0, cameraY
- vertBorderPixel_1, renderWidth + horBorderPixel_0, renderHeight
+ vertBorderPixel_1);
this.moveRect = new RectBox(cameraX - horBorderPixel_0, cameraY
- vertBorderPixel_1, renderWidth + horBorderPixel_0, renderHeight
+ vertBorderPixel_1);
this.UpdateCamera();
}
开发者ID:hellogithubtesting,项目名称:LGame,代码行数:25,代码来源:LObjectCamera.cs
示例3: EmulatorButton
public EmulatorButton(LTexture img, int w, int h, int x, int y,
bool flag, int sizew, int sizeh)
{
this.color = new LColor(LColor.gray.R, LColor.gray.G,
LColor.gray.B, 125);
img.LoadTexture();
if (flag)
{
this.bitmap = img.GetSubTexture(x, y, w, h);
}
else
{
this.bitmap = img;
}
if (bitmap.GetWidth() != sizew || bitmap.GetHeight() != sizeh)
{
LTexture tmp = bitmap;
this.bitmap = bitmap.Scale(sizew, sizeh);
if (tmp != null)
{
tmp.Dispose();
tmp = null;
}
}
this.bounds = new RectBox(0, 0, bitmap.GetWidth(), bitmap.GetHeight());
}
开发者ID:hellogithubtesting,项目名称:LGame,代码行数:28,代码来源:EmulatorButton.cs
示例4: Action
public static LNFollow Action(LNNode followedNode, RectBox rect) {
LNFollow follow = new LNFollow();
follow._followedNode = followedNode;
follow._boundarySet = true;
follow._boundaryFullyCovered = false;
follow.winRect = LSystem.screenRect;
follow.fullScreenSize = new Vector2f(follow.winRect.width,
follow.winRect.height);
follow.halfScreenSize = follow.fullScreenSize.Mul(0.5f);
follow.leftBoundary = -((rect.x + rect.width) - follow.fullScreenSize.x);
follow.rightBoundary = -rect.x;
follow.topBoundary = -rect.y;
follow.bottomBoundary = -((rect.y + rect.height) - follow.fullScreenSize.y);
if (follow.rightBoundary < follow.leftBoundary) {
follow.rightBoundary = follow.leftBoundary = (follow.leftBoundary + follow.rightBoundary) / 2;
}
if (follow.topBoundary < follow.bottomBoundary) {
follow.topBoundary = follow.bottomBoundary = (follow.topBoundary + follow.bottomBoundary) / 2;
}
if ((follow.topBoundary == follow.bottomBoundary)
&& (follow.leftBoundary == follow.rightBoundary)) {
follow._boundaryFullyCovered = true;
}
return follow;
}
开发者ID:207h2Flogintvg,项目名称:LGame,代码行数:29,代码来源:LNFollow.cs
示例5: Intersects
private bool Intersects(RectBox other) {
RectBox box = other;
Circle circle = this;
if (box.Contains(x + radius, y + radius)) {
return true;
}
float x1 = box.GetX();
float y1 = box.GetY();
float x2 = box.GetX() + box.GetWidth();
float y2 = box.GetY() + box.GetHeight();
Line[] lines = new Line[4];
lines[0] = new Line(x1, y1, x2, y1);
lines[1] = new Line(x2, y1, x2, y2);
lines[2] = new Line(x2, y2, x1, y2);
lines[3] = new Line(x1, y2, x1, y1);
float r2 = circle.GetRadius() * circle.GetRadius();
Vector2f pos = new Vector2f(circle.GetCenterX(), circle.GetCenterY());
for (int i = 0; i < 4; i++) {
float dis = lines[i].DistanceSquared(pos);
if (dis < r2) {
return true;
}
}
return false;
}
开发者ID:keppelcao,项目名称:LGame,代码行数:32,代码来源:Circle.cs
示例6: IsCircToCirc
/// <summary>
/// 判断两个圆形是否发生了碰撞
/// </summary>
///
/// <param name="rect1"></param>
/// <param name="rect2"></param>
/// <returns></returns>
public static bool IsCircToCirc(RectBox rect1, RectBox rect2)
{
Point middle1 = GetMiddlePoint(rect1);
Point middle2 = GetMiddlePoint(rect2);
float distance = middle1.DistanceTo(middle2);
float radius1 = rect1.GetWidth() / 2;
float radius2 = rect2.GetWidth() / 2;
return (distance - radius2) < radius1;
}
开发者ID:keppelcao,项目名称:LGame,代码行数:16,代码来源:CollisionHelper.cs
示例7: OutEffect
public OutEffect(LTexture t, RectBox limit, int code)
{
this.texture = t;
this.type = code;
this.width = t.Width;
this.height = t.Height;
this.multiples = 1;
this.limit = limit;
this.visible = true;
}
开发者ID:207h2Flogintvg,项目名称:LGame,代码行数:10,代码来源:OutEffect.cs
示例8: EmulatorButton
public EmulatorButton(LTextureRegion img, int w, int h, int x, int y,
bool flag, int sizew, int sizeh) {
if (flag) {
this.bitmap = new LTextureRegion(img, x, y, w, h);
} else {
this.bitmap = new LTextureRegion(img);
}
this.scaleWidth = sizew;
this.scaleHeight = sizeh;
this.bounds = new RectBox(0, 0, scaleWidth, scaleHeight);
}
开发者ID:207h2Flogintvg,项目名称:LGame,代码行数:11,代码来源:EmulatorButton.cs
示例9: CheckCollision
public bool CheckCollision(Actor actor)
{
obj0 = actor.GetRectBox();
dx = MathUtils.Abs(obj0.GetCenterX() - x);
dy = MathUtils.Abs(obj0.GetCenterY() - y);
dist = MathUtils.Sqrt(dx * dx + dy * dy);
return dist <= this.r;
}
开发者ID:darragh-murphy,项目名称:LGame,代码行数:12,代码来源:CollisionInRangeQuery.cs
示例10: Contains
public static bool Contains(int[] xPoints, int[] yPoints,
int nPoints,RectBox bounds, int x1, int y1)
{
if ((bounds != null && bounds.Inside(x1, y1))
|| (bounds == null && GetBoundingBox(xPoints, yPoints, nPoints)
.Inside(x1, y1)))
{
int hits = 0;
int ySave = 0;
int i = 0;
while (i < nPoints && yPoints[i] == y1)
{
i++;
}
for (int n = 0; n < nPoints; n++)
{
int j = (i + 1) % nPoints;
int dx = xPoints[j] - xPoints[i];
int dy = yPoints[j] - yPoints[i];
if (dy != 0)
{
int rx = x1 - xPoints[i];
int ry = y1 - yPoints[i];
if (yPoints[j] == y1 && xPoints[j] >= x1)
{
ySave = yPoints[i];
}
if (yPoints[i] == y1 && xPoints[i] >= x1)
{
if ((ySave > y1) != (yPoints[j] > y1))
{
hits--;
}
}
if (ry * dy >= 0
&& (ry <= dy && ry >= 0 || ry >= dy && ry <= 0)
&& Round(dx * ry, dy) >= rx)
{
hits++;
}
}
i = j;
}
return (hits % 2) != 0;
}
return false;
}
开发者ID:hellogithubtesting,项目名称:LGame,代码行数:53,代码来源:LGraphicsMath.cs
示例11: GetBounds
public static RectBox GetBounds(float x, float y, float width,
float height, float rotate, RectBox result)
{
int[] rect = GetLimit(x, y, width, height, rotate);
if (result == null)
{
result = new RectBox(rect[0], rect[1], rect[2], rect[3]);
}
else
{
result.SetBounds(rect[0], rect[1], rect[2], rect[3]);
}
return result;
}
开发者ID:keppelcao,项目名称:LGame,代码行数:14,代码来源:MathUtils.cs
示例12: SpriteBatchObject
public SpriteBatchObject(float x, float y, float dw, float dh,
Animation animation, TileMap map) {
this.SetLocation(x, y);
this.tiles = map;
this.animation = animation;
this.dstWidth = dw;
this.dstHeight = dh;
Loon.Core.Graphics.Opengl.LTexture texture = animation.GetSpriteImage();
if (dw < 1 && dh < 1) {
this.rectBox = new RectBox(x, y, texture
.GetWidth(), texture.GetHeight());
} else {
this.rectBox = new RectBox(x, y, dw, dh);
}
}
开发者ID:207h2Flogintvg,项目名称:LGame,代码行数:15,代码来源:SpriteBatchObject.cs
示例13: SpriteBatchObject
public SpriteBatchObject(float x, float y, float dw, float dh,
Animation animation, TileMap map)
{
this.SetLocation(x, y);
this.tiles = map;
this.animation = animation;
this.dstWidth = dw;
this.dstHeight = dh;
if (dw < 1 && dh < 1) {
this.rectBox = new RectBox(x, y, animation.GetSpriteImage()
.GetWidth(), animation.GetSpriteImage().GetHeight());
} else {
this.rectBox = new RectBox(x, y, dw, dh);
}
}
开发者ID:ordanielcmessias,项目名称:LGame,代码行数:15,代码来源:SpriteBatchObject.cs
示例14: GetIntersection
public static RectBox GetIntersection(RectBox a, RectBox b)
{
float a_x = a.GetX();
float a_r = a.GetRight();
float a_y = a.GetY();
float a_t = a.GetBottom();
float b_x = b.GetX();
float b_r = b.GetRight();
float b_y = b.GetY();
float b_t = b.GetBottom();
float i_x = MathUtils.Max(a_x, b_x);
float i_r = MathUtils.Min(a_r, b_r);
float i_y = MathUtils.Max(a_y, b_y);
float i_t = MathUtils.Min(a_t, b_t);
return (i_x < i_r && i_y < i_t) ? new RectBox(i_x, i_y, i_r - i_x, i_t
- i_y) : null;
}
开发者ID:ordanielcmessias,项目名称:LGame,代码行数:17,代码来源:RectBox.cs
示例15: SplitEffect
public SplitEffect(LTexture t, RectBox limit_0, int d)
{
this.texture = t;
this.width = texture.GetWidth();
this.height = texture.GetHeight();
this.halfWidth = width / 2;
this.halfHeight = height / 2;
this.multiples = 2;
this.direction = d;
this.limit = limit_0;
this.timer = new LTimer(10);
this.visible = true;
this.v1 = new Vector2f();
this.v2 = new Vector2f();
switch (direction)
{
case Config.UP:
case Config.DOWN:
special = true;
{
v1.Set(0, 0);
v2.Set(halfWidth, 0);
break;
}
case Config.TLEFT:
case Config.TRIGHT:
v1.Set(0, 0);
v2.Set(halfWidth, 0);
break;
case Config.LEFT:
case Config.RIGHT:
special = true;
{
v1.Set(0, 0);
v2.Set(0, halfHeight);
break;
}
case Config.TUP:
case Config.TDOWN:
v1.Set(0, 0);
v2.Set(0, halfHeight);
break;
}
}
开发者ID:207h2Flogintvg,项目名称:LGame,代码行数:44,代码来源:SplitEffect.cs
示例16: IsRectToCirc
/// <summary>
/// 检查矩形与圆形是否发生了碰撞
/// </summary>
///
/// <param name="rect1"></param>
/// <param name="rect2"></param>
/// <returns></returns>
public static bool IsRectToCirc(RectBox rect1, RectBox rect2)
{
float radius = rect2.GetWidth() / 2;
Point middle = GetMiddlePoint(rect2);
Point upperLeft = new Point(rect1.GetMinX(), rect1.GetMinY());
Point upperRight = new Point(rect1.GetMaxX(), rect1.GetMinY());
Point downLeft = new Point(rect1.GetMinX(), rect1.GetMaxY());
Point downRight = new Point(rect1.GetMaxX(), rect1.GetMaxY());
bool collided = true;
if (!IsPointToLine(upperLeft, upperRight, middle, radius))
{
if (!IsPointToLine(upperRight, downRight, middle, radius))
{
if (!IsPointToLine(upperLeft, downLeft, middle, radius))
{
if (!IsPointToLine(downLeft, downRight, middle, radius))
{
collided = false;
}
}
}
}
return collided;
}
开发者ID:keppelcao,项目名称:LGame,代码行数:31,代码来源:CollisionHelper.cs
示例17: Draw
public void Draw(LTexture texture, Vector2f pos, RectBox src,
bool flipX, bool flipY)
{
Draw(texture, pos.x, pos.y, src.width / 2, src.height / 2, src.width,
src.height, 1f, 1f, 0, src.x, src.y, src.width, src.height,
flipX, flipY, false);
}
开发者ID:hellogithubtesting,项目名称:LGame,代码行数:7,代码来源:SpriteBatch.cs
示例18: GetOnlyIntersectingUp
public Actor GetOnlyIntersectingUp(RectBox r,
CollisionQuery query, Actor actor, BSPCollisionNode start)
{
for (; start != null && !start.GetArea().Contains(r); )
{
Actor res = this.CheckForOnlyCollision(actor, start, query);
if (res != null)
{
return res;
}
start = start.GetParent();
}
return null;
}
开发者ID:keppelcao,项目名称:LGame,代码行数:14,代码来源:BSPCollisionChecker.cs
示例19: GetOnlyIntersectingDown
private Actor GetOnlyIntersectingDown(RectBox r,
CollisionQuery query, Actor actor)
{
if (this.bspTree == null)
{
return null;
}
else
{
lock (cacheNodeStack)
{
cacheNodeStack.Clear();
CollectionUtils.Add(cacheNodeStack, this.bspTree);
int idx = 0;
for (; !(cacheNodeStack.Count == 0) && idx < MAX_SIZE; )
{
BSPCollisionNode node = (BSPCollisionNode)cacheNodeStack
.RemoveLast();
if (node.GetArea().Contains(r))
{
Actor res = this.CheckForOnlyCollision(actor, node,
query);
if (res != null)
{
return res;
}
BSPCollisionNode left = node.GetLeft();
BSPCollisionNode right = node.GetRight();
if (left != null)
{
CollectionUtils.Add(cacheNodeStack, left);
}
if (right != null)
{
CollectionUtils.Add(cacheNodeStack, right);
}
}
}
}
return null;
}
}
开发者ID:keppelcao,项目名称:LGame,代码行数:43,代码来源:BSPCollisionChecker.cs
示例20: GetOnlyObjectDownTree
private Actor GetOnlyObjectDownTree(Actor ignore, RectBox r,
CollisionQuery query, BSPCollisionNode startNode)
{
if (startNode == null)
{
return null;
}
else
{
lock (cacheNodeStack)
{
cacheNodeStack.Clear();
if (startNode != null)
{
CollectionUtils.Add(cacheNodeStack, startNode);
}
while (!(cacheNodeStack.Count == 0))
{
BSPCollisionNode node = (BSPCollisionNode)cacheNodeStack
.RemoveLast();
if (node.GetArea().Intersects(r))
{
Actor res = this.CheckForOnlyCollision(ignore, node,
query);
if (res != null)
{
return res;
}
BSPCollisionNode left = node.GetLeft();
BSPCollisionNode right = node.GetRight();
if (left != null)
{
CollectionUtils.Add(cacheNodeStack, left);
}
if (right != null)
{
CollectionUtils.Add(cacheNodeStack, right);
}
}
}
}
return null;
}
}
开发者ID:keppelcao,项目名称:LGame,代码行数:44,代码来源:BSPCollisionChecker.cs
注:本文中的Loon.Core.Geom.RectBox类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论