Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello all,

 

For those that frequent the c# forum on gotdotnet this may look familiar

I'm trying to rewrite a c# program in vb.net as kind of a learning exercise into OO concepts in programming.

 

The c# Class including it's current constructors is as below....(incase you couldn't guess i'm re-writing a 2D-Game)

public class Sprite 
{ 
 public Sprite(Device device, string image) : this(device, image, 1) 
 { 
 } 

 /// <summary> 
 /// Allows the creation of a sprite given a filename and a number of 
 /// frames. The bitmap is assumed to be divided up into (frames) evenly- 
 /// sized sections horizontally, with each section consituting a single 
 /// frame of the animation. 
 /// </summary> 
 public Sprite(Device device, string image, int frames) : 
  this(device, new Bitmap(image), frames) 
 { 
 } 

 /// <summary> 
 /// Allows the creation of a sprite given a Bitmap object and a 
 /// number of frames. The bitmap is assumed to be divided up into 
 /// (frames) evenly- sized sections horizontally, with each 
 /// section consituting a single frame of the animation. 
 /// </summary> 
 public Sprite(Device device, Bitmap image, int frames) 
 { 
    //Game Code 
 } 
} 

The problem i'm having is replicating the ": this(...)" parts of the classes in vb.net.

So far thanks to help from peeps on c# forum i've got so far....

Public Class Sprite 

 ' Allows the creation of a sprite given just a DirectDraw Device 
 ' object and the name of a file where a bitmap lives. The bitmap 
 ' is assumed to have only a single frame. 
 Public Sub New(ByVal device As Device, ByVal image As String) 
   frames = 1 
 End Sub 

 ' Allows the creation of a sprite given a Bitmap object and a 
 ' number of frames. The bitmap is assumed to be divided up into 
 ' (frames) evenly- sized sections horizontally, with each 
 ' section consituting a single frame of the animation. 
 Public Sub New(ByVal device As Device, ByVal image As String, ByVal frames As Integer) 

 End Sub 

 Public Sub New(ByVal device as Device, ByVal image as Bitmap, ByVal frames as integer) 
    'Game Code 
 End Sub 

End Class 

 

I just dont' know how to emulate the this(..) part of the c#

 

If it helps according to meago on c# board (gotdotnet) an explanation of that statement is....

 

"Sprite(...) : this(...) tells C# to first call the same "Sprite" routine that matches the parameters enclosed in this(...) and then after executing that code return control back to this Sprite(...) routine and execute it..."

 

Can anyone help?

  • Administrators
Posted

' Allows the creation of a sprite given a Bitmap object and a 
 ' number of frames. The bitmap is assumed to be divided up into 
 ' (frames) evenly- sized sections horizontally, with each 
 ' section consituting a single frame of the animation. 
 Public Sub New(ByVal device As Device, ByVal image As String, ByVal frames As Integer) 
Me.New(device, new Bitmap(image), frames)
 End Sub 

or similar

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
' Allows the creation of a sprite given a Bitmap object and a 
 ' number of frames. The bitmap is assumed to be divided up into 
 ' (frames) evenly- sized sections horizontally, with each 
 ' section consituting a single frame of the animation. 
 Public Sub New(ByVal device As Device, ByVal image As String, ByVal frames As Integer) 
Me.New(device, new Bitmap(image), frames)
 End Sub 

or similar

 

Thanks PlausiblyDamp

That works fine

 

Cheers

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...