明确使用 Haxe API 类 [英] Use Haxe API classes explicitly
问题描述
我使用 Haxe 定位 Javascript.
I use Haxe targeting Javascript.
我有一个包(定义为外部)phaser
",其中包含一个 Math
类以及许多其他类.我在文件的开头使用了 import phaser.*;
,因为我使用了这个包中的许多类,我不想用 phaser.
.
I have a package (defined as an extern), "phaser
", that contains a Math
class along with many others.
I use import phaser.*;
at the beginning of my files because I use many classes from this package and I don't want to prefix them all with phaser.
.
我想使用 Haxe API 中的 Math 类,但是如果我尝试使用它(例如 Math.random()
),编译器认为我想使用 phaser.Math
并告诉我里面没有这样的函数.
I would like to use the Math class from Haxe API, but if I try to use it (e.g Math.random()
), the compiler thinks I want to use phaser.Math
and tells me there is no such function in it.
我可以明确写出我想使用 Haxe Math
类而不是 phaser.Math
吗?
Can I explicitly write that I want to use Haxe Math
class and not phaser.Math
?
我试过 haxe.Math
但没有运气...
I've tried haxe.Math
but no luck...
提前致谢
推荐答案
尝试
import Math as HaxeMath;
然后使用 HaxeMath.*
而不是 Math.*
注意,HaxeMath
这个名字没什么特别的,你可以做
Note, nothing special about the name HaxeMath
, you could do
import Math as Freddy;
然后使用 Freddy.*
而不是 Math.*
.:p
then use Freddy.*
instead of Math.*
. :p
这篇关于明确使用 Haxe API 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!