DeprecationWarning:必需为整数(got类型为float)。不建议使用
int
隐式转换为整数,并且可以在以后的Python版本中删除。
win.blit(playerStand, (x, y))
DeprecationWarning:必需为整数(got类型为float)。不建议使用
int
隐式转换为整数,并且可以在以后的Python版本中删除。
win.blit(walkLeft[animCount // 5], (x, y))
答案 0 :(得分:0)
警告与blit()
的坐标参数有关。浮点坐标将意味着Surface
的原点在窗口像素之间。那没有多大意义。坐标会自动隐式地截断,并通过警告指示。
使用int
或round
将浮点坐标转换为整数:
win.blit(playerStand, (round(x), round(y)))
答案 1 :(得分:-1)
该消息还会进行显式转换,因此,为了安全起见,请执行以下操作:
struct AnyShape: Shape {
init<S: Shape>(_ wrapped: S) {
_path = { rect in
let path = wrapped.path(in: rect)
return path
}
}
func path(in rect: CGRect) -> Path {
return _path(rect)
}
private let _path: (CGRect) -> Path
}
func shape(_ shape: SetGameModel.Card.Shape) -> some Shape {
if shape == .diamond {
return AnyShape(Diamond())
} else if shape == .squiggle {
return AnyShape(Rectangle())
} else {
return AnyShape(Ellipse())
}
}
W1JGH