逐个addEventListener碰撞(One by one addEventListener collision)
我正在制作一个简单的突破游戏,我遇到
ball:addEventListener( "collision", removeBricks )
问题ball:addEventListener( "collision", removeBricks )
,它可以正常运行,直到球同时击中两个砖块,而不是上/下方向(vy
)切换两次,使球继续向上或向下移动。如何逐个addEventListener碰撞并一次禁用多个碰撞?
function removeBricks(event) if event.other.isBrick == 1 then vy = vy * (-1) ... end end
I'm working on a simple breakout game and I've problem with
ball:addEventListener( "collision", removeBricks )
, it works fine until the ball hits two bricks at same time, than the up/down direction (vy
) switch twice, making the ball continue moving up or down.How can do one by one addEventListener collision and disable multiple collides at once?
function removeBricks(event) if event.other.isBrick == 1 then vy = vy * (-1) ... end end
原文:https://stackoverflow.com/questions/17345552
最满意答案
link: string;
足够了。您始终可以在属性中存储null,无论其类型如何。
link: string;
is sufficient.You can always store null in a property, whatever its type is.
相关问答
更多-
这是关于你的第一个渲染,它找不到todoText 。 因为它在constructor的初始化是错误的。 将constructor更改为: constructor(props:TodoProps){ super(props); this.state = { todoText:" " }; } It's about your first render, it can't find todoText. Because it's initial in the construct ...
-
link: string; 足够了。 您始终可以在属性中存储null,无论其类型如何。 link: string; is sufficient. You can always store null in a property, whatever its type is.
-
如果请更正,您正在进行分配操作 if (value.type = typePlace && value.id == idPlace) 至 if(value.type == typePlace && value.id == idPlace) 并请检查它的值不应该是一个字符串的类型。比较之前,你应该检查天气的类型属性是否存在。 You are doing assignment operation in if please correct if (value.type = typePlace && val ...
-
Angular2 EXCEPTION:无法读取null的属性'off'(Angular2 EXCEPTION: Cannot read property 'off' of null)[2022-12-10]
我认为你的模板应该是[attr.id]而不是attr.id 喜欢: template: '{{model }}' I'm not sure if this is the cause but i managed to fix it by removing the AfterContentChecked implementation. so before ... -
如果你想要执行这个异步,那么你需要实现AsyncValidator 。 你也需要返回observable的结果,而不是订阅它。 这里最简单的方法是使用Observable而不是promise,但是也可以在.map()之后链接.toPromise() 。 你不想在这里订阅你想要返回observable本身(或承诺),但你确实希望得到的承诺返回预期的结果,这就是为什么你应该使用map 。 在旁注中,我建议你切换到使用可操作的操作符,如果你还没有这样做的话。 另请参见在Angular rxjs中,我应该何时使用p ...
-
您可以使用箭头函数调用,如下所示: navigator.geolocation.getCurrentPosition((pos)=>this.setPosition(pos)) 或者如果它不发送参数, navigator.geolocation.getCurrentPosition(()=>this.setPosition()) You can call using arrow function like so: navigator.geolocation.getCurrentPosition((pos ...
-
尝试这个: subscribeItems(): Observable
- { return this.session.uid.subscribe(x => { return this.af.database.list('users/' + x + '/Items') .map(Item.fromJsonList => Item.fromJsonList.json()); }); return null; } Try thi ...
-
正如mickdev建议的......几乎是正确的,但是你得到了NaN错误,因为你已经将输入类型定义为text 。
{{val | doubleNumber}}
删除它,或替换为type="number" :{{val | doubleNumber}}
As mickdev suggested... i ... -
尝试使用safe navigation operator (?.)来防止属性路径中的空值和未定义值。This username is already taken
-
我可以看到你的代码有些问题。 对于初学者,你应该在你的锚标签中使用#name="first"而不是let name="first" 。 但是,你有多个ViewChildren具有相同的名称,它仍然无法正常工作。 访问原始DOM元素可能不是这里的答案。 我宁愿做这样的事情: import { Component, ElementRef, ViewChild } from '@angular/core'; @Component({ selector: 'my-app', template: ` ...