2017-06-17 63 views
-1
tail = 5; 

这是尾部起始长度。蛇吃苹果时,我该如何让尾巴长度增加?

if(ax==px && ay==py) { 
    tail++; 
    ax=Math.floor(Math.random()*tc); 
    ay=Math.floor(Math.random()*tc); 
} 

尾++是什么,我想改变,但我不能让它为特定的金额只是添加到尾部的长度。

+1

'tail + = mySpecificAmount;'? – PeterMader

+0

@PeterMader谢谢 –

回答

1

tail++;tail的值增加1。它与tail = tail + 1;相同。

如果您想通过其他值更改(例如,5),请执行以下操作:tail += 5;。它与tail = tail + 5;相同。