我正在使用LibGdx中的声音界面来播放mp3音频文件.当选择循环播放声音不止一次使用sound.loop();它时,但每次声音重播时都会有很小的静音时间.那么有什么方法可以摆脱这个沉默时期或者比我使用的那个更流畅地播放音效?
这是我的代码:
Sound accelarating_sound1;
accelarating_sound1 = Gdx.audio.newSound(Gdx.files.internal("speedUp.mp3"));
accelarating_sound1.loop(1,f,0);
Run Code Online (Sandbox Code Playgroud) 我有以下代码:
ignored := [ "Rainmeter.exe", "Nimi Places.exe", "mumble.exe" ]
a := ignored.HasKey("mumble.exe")
MsgBox,,, %a%
Run Code Online (Sandbox Code Playgroud)
0即使字符串明确存在于数组中,它也会返回.
如何测试数组中是否存在字符串值?
PS:我也尝试if var in了同样的结果.
我想尝试镜头,Monocle库似乎(从我的无声的角度来看)很好用所有那些花哨的样板@Lenses.不幸的是,我发现初学者没有什么非学习材料(我知道香草Scala的基础知识,没有Scalaz).官方教程缺少简单的示例(和/或其结果),并且在非常复杂的Scalaz库中混合使用.人们会认为在第一页上会涉及到访问地图这样的微不足道的任务.
我有以下片段:
@Lenses case class House(presentsDelivered: Int)
type Houses = Map[(Int, Int), House]
@Lenses case class Town(houses: Houses)
@Lenses case class Santa(x: Int, y: Int)
@Lenses case class World(santa: Santa, town: Town)
Run Code Online (Sandbox Code Playgroud)
我看到了at和index,但没有简单的例子(只是一些奇怪[魔术对我来说]与回答applyOptional这需要样板).我想更新地图 - houses在Town.我正在尝试这种精神:
(World.town ^|-> Town.houses ^|-> index((x, y)) ^|-> House.presentsDelivered)
.modify { _ + 1 }(world)
Run Code Online (Sandbox Code Playgroud)
这在语法上是错误的,但我认为这是明显的就是我想要做的(修改presentsDelivered的House在指定x, y坐标).所以我的问题是,如何修改index部件以访问地图?
欢迎任何帮助,线索或noob友好的学习材料提示.
我喜欢let在Scala中构造类似于Haskell的构造.我尝试了几种方法,但似乎没有一种方法.这是一些代码:
object CustomLet extends App {
val data = for (i <- 1 to 1024; j <- 1 to 512) yield (i % j) * i * (i + 1) - 1
def heavyCalc() = { println("heavyCalc called"); data.sum }
def doSomethingWithRes(res: Int) = {
println(s"${res * res}")
1
}
def cond(value: Int): Boolean = value > 256
// not really usable, even though it's an expression (2x heavyCalc calls)
def withoutLet() = if (cond(heavyCalc())) doSomethingWithRes(heavyCalc()) else 0 …Run Code Online (Sandbox Code Playgroud) 我有一个CtMethod实例,但我不知道如何从中获取参数(不是类型)的名称.我试过getParameterTypes,但它似乎只返回类型.
我假设它是可能的,因为我使用的库没有源代码,只有类文件,我可以在IDE中看到方法参数的名称.
如何让REPL导入commnad行中给出的包?
样品:
scala -someMagicHere "import sys.error"
scala> :imports
1) import scala.Predef._ (162 terms, 78 are implicit)
2) import sys.error (2 terms)
scala> _
Run Code Online (Sandbox Code Playgroud)
PS:这不是重复的.我想要自动化解决方案,而不是每次运行REPL时手动粘贴一些代码.另外,我不想仅仅为了在REPL启动后在REPL中运行一个命令而使用SBT.
我打开了一些编译器开关,以报告代码中的更多问题(例如,严格的null检查)。但是我在使用的库中遇到了几十个错误,例如:
[default] xxx/node_modules/@angular/core/src/util/decorators.d.ts:11:5
Property 'extends' of type 'Type<any> | undefined' is not assignable to string index type 'Function | any[] | Type<any>'.
Run Code Online (Sandbox Code Playgroud)
有什么方法可以抑制/消除/禁用库(例如目录node_modules)中的错误检查?
它不能与“ 仅允许用于定义文件”隐式允许重复,因为我的问题要广泛得多。我不是在问如何禁用库中的一项特定检查(noImplicitAny),而是如何禁用库中的所有检查。但是,该问题的答案也适用于我的- "skipLibCheck": true禁用库中的所有检查。
我无法理解为什么这段代码错了,错误信息是:
error: '}' expected but '.' found.
Run Code Online (Sandbox Code Playgroud)
在线
this.tX = cX
Run Code Online (Sandbox Code Playgroud)
码:
class Quaternion {
private var tX: Float = 0
private var tY: Float = 0
private var tZ: Float = 0
private var tW: Float = 1
def this(cX: Float, cY: Float, cZ: Float, cW: Float) {
this.tX = cX
this.tY = cY
this.tZ = cZ
this.tW = cW
}
...
Run Code Online (Sandbox Code Playgroud)
请帮我解决我可能明显的错误.
Scala是否有类似于JavaScript的东西with,或者它可以以某种方式实现(例如库,隐含或宏)?
with在JS中的示例:
function p(){
document.write("I am " + this.constructor.name + ".<br>");
}
function o1(){
this.p = p;
}
var i1 = new o1();
i1.p();
p();
with(i1){ p(); }
Run Code Online (Sandbox Code Playgroud)
输出:
I am o1.
I am Window.
I am o1.
Run Code Online (Sandbox Code Playgroud)
我正在寻找的例子:
class A { def x { ... } }
val a = new A
with(a){ x }
Run Code Online (Sandbox Code Playgroud)
只有我发生的事情是使用匿名函数,但它只是一个名称替换,仅此而已(而且它非常冗长).
( (aa:A) => aa.x )(a)
Run Code Online (Sandbox Code Playgroud) scala ×5
syntax ×2
angular ×1
arrays ×1
autohotkey ×1
constructor ×1
contains ×1
javascript ×1
javassist ×1
let ×1
libgdx ×1
string ×1
typescript ×1