0
this.collision = function(p1, p2, p3, p4)
{
if(this.ballY - this.radius + this.dy <= p1.height && this.ballX + this.dx >= p1.leftPostx - p1.goalPostRadius && this.ballX <= p1.rightPostx + p1.goalPostRadius)
{
this.dy = -this.dy;
this.ballY = p1.height + this.radius;
count++;
score++;
<?php $_SESSION['score'] += 1; ?>
}
else if(this.ballY + this.radius + this.dy >= canvas.height - p2.height && this.ballX + this.dx >= p2.leftPostx - p2.goalPostRadius && this.ballX + this.dx <= p2.rightPostx + p2.goalPostRadius)
{
this.dy = -this.dy;
this.ballY = canvas.height - p2.height - this.radius;
count++;
score++;
<?php $_SESSION['score'] += 1; ?>
}
else if(this.ballX + this.radius + this.dx >= canvas.width - p3.height && this.ballY + this.dy >= p3.topPosty - p3.goalPostRadius && this.ballY + this.dy <= p3.bottomPosty + p3.goalPostRadius)
{
this.dx = -this.dx;
this.ballX = canvas.width - p3.height - this.radius;
count++;
score++;
<?php $_SESSION['score'] += 1; ?>
}
else if(this.ballX - this.radius + this.dx <= p4.height && this.ballY + this.dy >= p4.topPosty - p4.goalPostRadius && this.ballY + this.dy <= p4.bottomPosty + p4.goalPostRadius)
{
this.dx = -this.dx;
this.ballX = p4.height + this.radius;
count++;
score++;
<?php $_SESSION['score'] += 1; ?>
}
else if(this.ballY - this.radius + this.dy < 0 || this.ballY + this.radius + this.dy > canvas.height || this.ballX - this.radius + this.dx < 0 || this.ballX + this.radius + this.dx > canvas.width)
{
checkLives(p1, p2, p3, p4, ball1);
}
}
したがって、タイトルはそれをすべて示しています。このコードでは、セッション変数をインクリメントするときを判断するためにjavascript条件を使用しようとしています。これどうやってするの?みんな助けてくれてありがとう!JS内のPHPセッションを増やす
明日は、ありがとう! –
だから、うまくいけば私はこれを正しく理解しています。これでJSスコア変数の値がserverfile.phpにポストされ、セッションが更新されます。 serverfile.phpにsession_start()も必要ではないでしょうか? –
このファイルが含まれる前にあなたのコードの任意のファイルに入っていればあなたのフレームワークを知っていません。セッション開始が開始されてからセッションを開始する必要はありません。 –