这个问题完全是关于TypeScript的。如果我在Cocos Creator中有基于JavaScript的Cocos项目,那么我遇到的问题就可以很好地解决。
文件中有以下枚举,称为枚举。
export const enum CollisionType {
Static= 0,
Dynamic= 1,
Solid= 2,
SemiSolid= 3
}
在我的game.ts文件中,我具有以下内容
import {CollisionType} from "./Enums";
export default class PlayerControl extends cc.Component {
@property (CollisionType)
collisionType:CollisionType = CollisionType.Static;
,但是不幸的是,这不起作用。我在CollisionType下收到一条红线,并出现以下错误:
Argument of type 'typeof CollisionType' is not assignable to parameter of type 'string | number | boolean | Function | any[] | { type?: any; visible?: boolean | (() => boolean); displayName?: string; tooltip?: string; multiline?: boolean; readonly?: boolean; min?: number; max?: number; ... 7 more ...; animatable?: boolean; } | ValueType'.
如果我未将@property设置为我的变量,则可以正常使用,但此值无法在Cocos Creator编辑器中进行编辑。
有什么想法吗?
答案 0 :(得分:2)
尝试以下代码
library(tidyverse)
iris %>%
mutate(out1 = Sepal.Length < 6,
out2 = Sepal.Length < 5) %>%
group_by(Species) %>%
summarise(p1 = mean(out1),
p2 = mean(out2),
pdiff = p1 - p2,
p1_test = list(prop.test(sum(out1), length(out1))), # create tests for p1, p2 and diff and save the outputs as list
p2_test = list(prop.test(sum(out2), length(out2))),
pdiff_test = list(prop.test(c(sum(out1),sum(out2)), c(length(out1),length(out2)))),
p1_low = map_dbl(p1_test, ~.$conf.int[1]), # extract low and high confidence intervals based on the corresponding test
p1_high = map_dbl(p1_test, ~.$conf.int[2]),
p2_low = map_dbl(p2_test, ~.$conf.int[1]),
p2_high = map_dbl(p2_test, ~.$conf.int[2]),
pdiff_low = map_dbl(pdiff_test, ~.$conf.int[1]),
pdiff_high = map_dbl(pdiff_test, ~.$conf.int[2])) %>%
select(-matches("test")) # remove test columns
# # A tibble: 3 x 10
# Species p1 p2 pdiff p1_low p1_high p2_low p2_high pdiff_low pdiff_high
# <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
# 1 setosa 1 0.4 0.6 0.911 1 0.267 0.548 0.444 0.756
# 2 versicolor 0.52 0.02 0.5 0.376 0.661 0.00104 0.120 0.336 0.664
# 3 virginica 0.14 0.02 0.12 0.0628 0.274 0.00104 0.120 -0.00371 0.244