我在vb.net上制作picbox有困难 [英] Im having trouble making picboxs in vb.net

查看:74
本文介绍了我在vb.net上制作picbox有困难的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个简单的游戏,试图在编码方面做得更好。游戏的重点是有一个角色闪避下降块。我正在尝试做的是制作能够容纳下降的块图片的图片框。我在学校做过这样的项目,但没有
让我们做的就是我们所做的就是将它们生成到屏幕上的随机点上。我遇到的问题是让他们加载到屏幕上。我会分享我的代码中似乎不起作用的部分,如果需要,可以分享整个事情。感谢谁花了他们
的时间来帮助我。 

I've made a simple game to try and get better at coding. The point of the game is having a character dodge falling blocks. What i'm trying to do is make picture boxes that hold the blocks picture that will fall. I did a project like this in school but not making them fall all we did was generate them onto random spots on screen. The problem i'm having is getting them to load on screen. Ill share the part of my code that doesn't seem to work and if needed share the whole thing. thank you to whoever takes their time to help me out. 

一些注释..

计时器是启用后,我按下启动时将其设置为启用。 

the timer is enabled, i have it set to enabled when i press start. 

代码返回此错误

System.NullReferenceException:'对象引用不是设置为对象的实例。'

System.NullReferenceException: 'Object reference not set to an instance of an object.'

此行

p.Left = generator.Next(0,Height)

p.Left = generator.Next(0, Height)

推荐答案


代码返回此错误

The code returns this error

System.NullReferenceException :'对象引用未设置为对象的实例。'

System.NullReferenceException: 'Object reference not set to an instance of an object.'

此行

p.Left = generator.Next (0,高度)

p.Left = generator.Next(0, Height)

该消息告诉您变量'generator'引用Nothing - 它尚未初始化,因此它指的是对象。

The message is telling you that the variable 'generator' refers to Nothing - it has not been initialised so that it refers to an object.

您应该查看该变量的声明和使用方式,并确定将其初始化为何种对象。 什么对象有Next方法? 生成器应该初始化为Random对象吗?如果是这样,通常会以
形式加载方法。

You should look at how that variable is declared and used, and work out what sort of object you need to initialise it to.  What object has a Next method?  Should generator be initialised to a Random object? If so, that usually happens in a form load method.


这篇关于我在vb.net上制作picbox有困难的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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