本文整理汇总了C#中Loon.Core.Geom.RectBox类的典型用法代码示例。如果您正苦于以下问题:C# RectBox类的具体用法?C# RectBox怎么用?C# RectBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RectBox类属于Loon.Core.Geom命名空间,在下文中一共展示了RectBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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();
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
}