- Home /
The question is answered, right answer was accepted
Camera won't scroll - iTween
Hi! I'm having a little problem with scrolling lately. The game is for Android platform. It works fine for the first time. However, after I select a level, play it, and return to the main menu, the scrolling stops working.
Here is my script which attached to the camera:
//Store the object for the chapter selection
var chapter : Transform[];
var currentChapter : int = 0;
var level : Transform[];
function Start () {
currentChapter = 0;
}
function Update () {
//Phase Moving
if (Input.touchCount > 0.0 && Input.GetTouch(0).phase == TouchPhase.Moved) {
//Check the location of finger
var deltaPos : Vector2 = Input.GetTouch(0).deltaPosition;
//Scroll Right
if (deltaPos.x < -6) {
//Check the array Length
if (currentChapter < chapter.length - 1) {
//Check the position, no double scroll
if ((transform.position.x > chapter[currentChapter].position.x - 0.5) &&
(transform.position.x < chapter[currentChapter].position.x + 0.5)) {
//Scroll
iTween.MoveTo (gameObject, {"x" : chapter[currentChapter + 1].position.x, Time : 0.8});
print ("Scroll Right");
currentChapter ++;
}
}
}
//Scroll Left
if (deltaPos.x > 6) {
if (currentChapter > 0) {
//Check the position, no double scroll
if ((transform.position.x > chapter[currentChapter].position.x - 0.5) &&
(transform.position.x < chapter[currentChapter].position.x + 0.5)) {
//Scroll
iTween.MoveTo (gameObject, {"x" : chapter[currentChapter - 1].position.x, Time : 0.8});
print ("Scroll Left");
currentChapter --;
}
}
}
}
}
As you can see, I use iTween to move the camera. Though the scrolling isn't working but the printing of (scrolling right or left) is working normal. I have been spending a couple days trying to get this work. But no good result yet. Hope somebody can help me. Thanks in advance!!!
There is nothing wrong with this script. It was my another script which is messing with the timeScale.
Follow this Question
Related Questions
Possible to use an external camera (USB) while running on Android? 1 Answer
Dragging Camera based on Touch 0 Answers
Android: Game not fitting on screen 1 Answer
Camera Size on Android 0 Answers
WebCamTexture crashes on android 0 Answers