vb.net - problem im code

03/16/2010 21:20 waldi_#1
Hey Leute
Um mich ein bisschen in XNA und Visual Basic umzuschauen hab ich versucht das Platform Game - Beispiel von C# XNA Game Studio zu übersetzen (gibt im inet en übersetzer, is recht leicht weil ja beide codes in einen gleichen zwischencode übersetzt werden beim compilieren)

so, nun hab ich alle klasen übersetzt und hinzugefügt, zeigt auch keine fehler an außer bei einer Zeile:

Code:
Imports System
Imports Microsoft.Xna.Framework
Imports Microsoft.Xna.Framework.Graphics

Namespace Platformer1
    ''' <summary>
    ''' Controls playback of an Animation.
    ''' </summary>
    Structure AnimationPlayer
        ''' <summary>
        ''' Gets the animation which is currently playing.
        ''' </summary>
        Public ReadOnly Property Animation() As Animation
            Get
                Return m_animation
            End Get
        End Property
        Private m_animation As Animation

        ''' <summary>
        ''' Gets the index of the current frame in the animation.
        ''' </summary>
        Public ReadOnly Property FrameIndex() As Integer
            Get
                Return m_frameIndex
            End Get
        End Property
        Private m_frameIndex As Integer

        ''' <summary>
        ''' The amount of time in seconds that the current frame has been shown for.
        ''' </summary>
        Private time As Single

        ''' <summary>
        ''' Gets a texture origin at the bottom center of each frame.
        ''' </summary>
        Public ReadOnly Property Origin() As Vector2
            Get
                Return New Vector2(Animation.FrameWidth / 2.0F, Animation.FrameHeight)
            End Get
        End Property

        ''' <summary>
        ''' Begins or continues playback of an animation.
        ''' </summary>
        Public Sub PlayAnimation(ByVal animation__1 As Animation)
            ' If this animation is already running, do not restart it.
            If [COLOR="Red"]animation__1 = animation[/COLOR] Then
                Exit Sub
            End If

            ' Start the new animation.
            Me.m_animation = animation__1
            Me.m_frameIndex = 0
            Me.time = 0.0F
        End Sub

        ''' <summary>
        ''' Advances the time position and draws the current frame of the animation.
        ''' </summary>
        Public Sub Draw(ByVal gameTime As GameTime, ByVal spriteBatch As SpriteBatch, ByVal position As Vector2, ByVal spriteEffects As SpriteEffects)
            If Animation Is Nothing Then
                Throw New NotSupportedException("No animation is currently playing.")
            End If

            ' Process passing time.
            time += CSng(gameTime.ElapsedGameTime.TotalSeconds)
            While time > Animation.FrameTime
                time -= Animation.FrameTime

                ' Advance the frame index; looping or clamping as appropriate.
                If Animation.IsLooping Then
                    m_frameIndex = (m_frameIndex + 1) Mod Animation.FrameCount
                Else
                    m_frameIndex = Math.Min(m_frameIndex + 1, Animation.FrameCount - 1)
                End If
            End While

            ' Calculate the source rectangle of the current frame.
            Dim source As New Rectangle(FrameIndex * Animation.Texture.Height, 0, Animation.Texture.Height, Animation.Texture.Height)

            ' Draw the current frame.
            spriteBatch.Draw(Animation.Texture, position, source, Color.White, 0.0F, Origin, _
             1.0F, spriteEffects, 0.0F)
        End Sub
    End Structure
End Namespace
Das Rote ist der Fehler, hier die Fehlerbeschreibung:
Der =-Operator ist für die Typen "Spiel1.Platformer1.Animation" und "Spiel1.Platformer1.Animation" nicht definiert.

Animation is ne Klasse..

hat jemand ne idee an was es liegen könnte?
ich will eig nur das der code funktioniert um ihn dann genauer anzuschauen :o
03/16/2010 21:42 xNopex#2
Versuch mal das für die rote Zeile:

Code:
If animation__1 = Me.m_animation Then
Wäre für mich jetzt am logischsten, nachdem ich kurz über den Code geschaut hab.
03/16/2010 21:45 waldi_#3
geht auch nich :/


Hier der Code von der klasse animation:

Code:
Imports System
Imports Microsoft.Xna.Framework.Graphics

Namespace Platformer1
    ''' <summary>
    ''' Represents an animated texture.
    ''' </summary>
    ''' <remarks>
    ''' Currently, this class assumes that each frame of animation is
    ''' as wide as each animation is tall. The number of frames in the
    ''' animation are inferred from this.
    ''' </remarks>
    Class Animation
        ''' <summary>
        ''' All frames in the animation arranged horizontally.
        ''' </summary>
        Public ReadOnly Property Texture() As Texture2D
            Get
                Return m_texture
            End Get
        End Property
        Private m_texture As Texture2D

        ''' <summary>
        ''' Duration of time to show each frame.
        ''' </summary>
        Public ReadOnly Property FrameTime() As Single
            Get
                Return m_frameTime
            End Get
        End Property
        Private m_frameTime As Single

        ''' <summary>
        ''' When the end of the animation is reached, should it
        ''' continue playing from the beginning?
        ''' </summary>
        Public ReadOnly Property IsLooping() As Boolean
            Get
                Return m_isLooping
            End Get
        End Property
        Private m_isLooping As Boolean

        ''' <summary>
        ''' Gets the number of frames in the animation.
        ''' </summary>
        Public ReadOnly Property FrameCount() As Integer
            Get
                Return Texture.Width / FrameWidth
            End Get
        End Property

        ''' <summary>
        ''' Gets the width of a frame in the animation.
        ''' </summary>
        Public ReadOnly Property FrameWidth() As Integer
            ' Assume square frames.
            Get
                Return Texture.Height
            End Get
        End Property

        ''' <summary>
        ''' Gets the height of a frame in the animation.
        ''' </summary>
        Public ReadOnly Property FrameHeight() As Integer
            Get
                Return Texture.Height
            End Get
        End Property

        ''' <summary>
        ''' Constructors a new animation.
        ''' </summary>        
        Public Sub New(ByVal texture As Texture2D, ByVal frameTime As Single, ByVal isLooping As Boolean)
            Me.m_texture = texture
            Me.m_frameTime = frameTime
            Me.m_isLooping = isLooping
        End Sub
    End Class
End Namespace