Given this type definition:
type
Asset* = ref object of RootObj
position*: Vertex
flip*: LCDBitmapFlip
Texture* = ref object of Asset
image*: LCDBitmap
Animation* = ref object of Asset
bitmapTable*: LCDBitmapTable
frameCount*: int32
startOffset*: int32
This code will compile:
let annotatedTable = getOrLoadBitmapTable(BitmapTableId.Flag)
let animation: Animation = Animation(
bitmapTable: annotatedTable.bitmapTable,
frameCount: annotatedTable.frameCount,
position: position,
flip: if hFlip: kBitmapFlippedX else: kBitmapUnflipped,
startOffset: 0'i32,
)
But this code will not compile
proc newAnimation(bitmapTableId: BitmapTableId, position: Vertex, flip: LCDBitmapFlip, randomStartOffset: bool): Animation =
let annotatedTable = getOrLoadBitmapTable(bitmapTableId)
return Animation(
bitmapTable: annotatedTable.bitmapTable,
frameCount: annotatedTable.frameCount,
position: position,
flip: flip,
startOffset: 0'i32,
)
let animation: Animation = newAnimation(
bitmapTableId: BitmapTableId.Flag,
position: position,
flip: if hFlip: kBitmapFlippedX else: kBitmapUnflipped,
randomStartOffset: true
)
Tjhhe compiler only tells me ` Error: type expected` at the let animation: Animation = newAnimation( line.
As far as I know, I provided types where possible. the newAnimation proc on its own, without usage, compiles fine
Procedure calls must use = with named arguments and not :, e.g.
let animation: Animation = newAnimation(
bitmapTableId = BitmapTableId.Flag,
position = position,
flip = if hFlip: kBitmapFlippedX else: kBitmapUnflipped,
randomStartOffset = true
)