Dobrý den. Píšu si hru v XNA jako náhražka starého hada z Nokie. Ale zde mi to ukáže chybu "Odkaz na objekt není nastaven na instanci objektu.", ale nechápu jak to mám vyřešit:
Private WithEvents graphics As GraphicsDeviceManager
Private WithEvents spriteBatch As SpriteBatch
Dim snake() As Sprite
Dim sTexture As Texture2D
'1: nahoru, 2: dolu, 3: doleva, 4:doprava
Dim smer As Integer
Dim stsmer As Integer
Public Sub New()
graphics = New GraphicsDeviceManager(Me)
graphics.PreferredBackBufferWidth = 150
graphics.PreferredBackBufferHeight = 150
Content.RootDirectory = "Content"
End Sub
''' <summary>
''' Allows the game to perform any initialization it needs to before starting to run.
''' This is where it can query for any required services and load any non-graphic
''' related content. Calling MyBase.Initialize will enumerate through any components
''' and initialize them as well.
''' </summary>
Protected Overrides Sub Initialize()
' TODO: Add your initialization logic here
MyBase.Initialize()
End Sub
''' <summary>
''' LoadContent will be called once per game and is the place to load
''' all of your content.
''' </summary>
Protected Overrides Sub LoadContent()
' Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = New SpriteBatch(GraphicsDevice)
sTexture = Content.Load(Of Texture2D)("telo")
' ZDE:
snake(0) = New Sprite(sTexture, New Rectangle(1, 1, 1, 1))
End Sub
Neměl by někdo radu? Děkuji předem.
|