How do you cast from int to Key Enum?

About Monkey 2 Forums Monkey 2 Programming Help How do you cast from int to Key Enum?

This topic contains 2 replies, has 2 voices, and was last updated by  AdamStrange 1 year, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #12570

    AdamStrange
    Participant

    Title says it. How do you convert an into to an enum.

    E.G.
    local i:int = Key.Space
    i now is 32 which is an int or enumerated position

    How to do the reverse?
    E.G.
    local k:Key = 32

    Error cant cast from int to enum!!!!

    #12571

    Jesse
    Participant

    Local i:Int = Key.Space
    Local k:Key = Cast<Key>(i)
    Print Int(k)

    #12572

    AdamStrange
    Participant

    brilliant 🙂
    I thought it was a cast, but just couldn’t get it to work. This just exactly what I wanted… Thankyou

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.