PictureBox的位置,如果 [英] PictureBox Location With If

查看:50
本文介绍了PictureBox的位置,如果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要这样的代码:

if (Picturebox-sonic.location == Picturebox-Enemies.location)
{
//Do stuff for me or I will get yo' life ! :3
}



所以在代码中,我想让我的图片框触摸另一个p.box并为我做一些事情.
我们可以将位置代码设为.Top或.left吗?

谢谢伙计们!



So inside the code i want to make my picturebox touch the other p.box and do somethin'' fo me.
We can make da Location code to .Top or .left ?

Thankz guys !

推荐答案

那将永远不会成为真,因为您必须比较位置属性来确定相等性:

That will never evaluate to true because you have to compare the location properties to determine equality:

if (sonic.Location.X == enemies.Location.X && sonic.Location.Y == enemies.Location.Y)
{
    // the points are the same
}




or

if (sonic.Location.Equals(enemies.Location))
{
    // the points are the same
}


看看您发布的代码!看起来您正在尝试从类型PictureBox的对象减去类型Location的对象.

此类操作未定义,因此代码甚至无法编译. :-)

—SA
Just look at the code you''ve posted! It looks like you are trying to subtract the object of the type Location from the object of the type PictureBox.

Such operation is not defined, so the code won''t even compile. :-)

—SA


别笑我的代码家伙.在这段代码之后,我将完成我的C#游戏(就像Worlds Hardest Game 1一样)

而且,我,才12岁.所以我已经为孩子做了很多脑力劳动.

@John Simmons/非法程序员

无论如何,感谢约翰·西蒙斯(John Simmons)的可能解决方案. ;)

@ SAKryukov276K

杜德..让我告诉你我12岁.这将是我的第一场比赛.它结束了.最后,我在约翰的帮助下修复了最后一个代码.迷路了.

我已经在游戏中做了很多工作,(我也在做另一个项目.只是学习.还在.)
Dont laugh to my codes dude. after this code i gonna finish my C# game ( its like Worlds Hardest Game 1)

And , Im , Just , 12 YEARS OLD. So already im doing so much brain work for a kid.

@John Simmons / outlaw programmer

Anyways , Thanks for the possible solution John Simmons. ;)

@SAKryukov276K

Dude.. let me to tell ya'' im 12 years old. This gonna be my first game. it ends. finally i fixed last code with help of John. Be lost.

I done a lot of a work in my game already , ( Im working another projects too. Just learning. still.)


这篇关于PictureBox的位置,如果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆