int gotoFrame(int frame) { if (frame < 0) { return _currentIndex = 0; } else if (frame >= totalFrame) { return _currentIndex = totalFrame - 1; } else { return _currentIndex = frame; } }