C
C#13mo ago
Slazmaz

Passing parameters to overloaded constructor

How would I pass the texture2D variable to be handled in the second constructor. Obviously return does not work but that is what I would do if it is was an overloaded function and not a constructor.
No description
5 Replies
ben SKVU4-9YBC
ben SKVU4-9YBC13mo ago
public Sprite(...) : this(...)
Slazmaz
SlazmazOP13mo ago
but that wouldn't allow me to pass the new texture2d variable?
ben SKVU4-9YBC
ben SKVU4-9YBC13mo ago
sure it would. public Sprite(string texture, ...) : this(Assets.Textures[texture], ...) {}
Slazmaz
SlazmazOP13mo ago
oh yea that did the trick, thanks!
ben SKVU4-9YBC
ben SKVU4-9YBC13mo ago
no problem

Did you find this page helpful?