fix the bug when spritearray is empty