setInterval()を使いこなそうとしたが、私が望む結果を得ることができないので、 。 globalTick()内の各スプライトの遅延ティック()JS
私はclass Arrow{
constructor(dirCode){
this.dirCode = dirCode;
this.speedX = 1
this.speedY = 1
switch(this.dirCode){
// ...
}
tick(){
ctx.fillStyle = "black"
ctx.fillRect(this.x, this.y, spriteSize, spriteSize)
switch(this.dirCode){
case 0:
this.x += this.speedX
break
case 1:
this.x += this.speedX
this.y -= this.speedY
break
// ...
アイブ氏は君たちに変数を惜しまこの場合、矢印オブジェクト、私のスプライトにこのglobalTick()
function globalTick(){
ctx.clearRect(0,0,800,800)
if(target){
target.tick();
}
// Move arrows
for(var i = 0; i < spriteList.length; i++){
spriteList[i].tick()
}
window.requestAnimationFrame(globalTick);
}
document.onkeyup = function(e){
// Change gamestate
if(e.which == 13){
$("#state"+gameState).hide()
gameState ++
if(gameState == 6){
// Affect game variables
player = new Player(0);
target = new Target(targetX, targetY)
for(var i = 0; i < player.calculateNotes(); i++){
timerID = setInterval(spawnArrows(), 3000)
}
clearInterval(timerID)
}
// ...
spawnArrows = function(){
// Rabdomize arrows (15 for now)
var dirCode = Math.floor((Math.random() * 8));
spriteList.push(new Arrow(dirCode))
//soundsSequence.push(soundsList[dirCode])
}
は、その後、私はこのダニを(持っている)メソッドを持っています宣言
私が望むのは、新しいArrowを別のオブジェクト内に存在する設定時間だけArrayにプッシュするのを遅らせることです。この例では3秒と言います。それは、requestAnimationFrameによって60回程度呼び出されているglobalTick()内で減速することも可能ですか?理想的には純粋なJSでは、JQueryが唯一の方法でない限り...
多くの感謝、これは十分に願っています!
ここをご覧くださいhttp://stackoverflow.com/questions/42318765/how-can-i-make-3-thousand-requests-to-google-drive-api-using-node-js-without-exc約束で滝を作る方法 –