- Home /
Need help with iTween manual skip and device hang
Hello all! I have been struggling for about a week with this problem. I make comic animations using iTween. I need some help on fixing this code. The idea is that the user can skip/speed up the comic by tapping. I stop the current iTween and set it manually at the final position, and just run the next iTween. The problem: the iPad or iPod device sometimes hangs when I try to skip the comics. Here is the code I'm using:
#pragma strict
#pragma downcast
public var fadeInTime:float;
public var timePerFrame:float = 2;
public var plane1: GameObject;
public var slideSpeed: float = 25;
public var scaleSpeed: float = 1;
public var canSkip: boolean = true;
private var plane1Scale: Vector3;
private var currentFrame: int=0;
function Start() {
iTween.CameraFadeAdd();
iTween.CameraFadeFrom({
"amount":1,
"time":fadeInTime,
"onComplete":"comicsStart",
"onCompleteTarget":transform.gameObject
});
}
function Awake() {
plane1Scale=plane1.transform.localScale;
}
function Update() {
getInput();
}
function comicsStart() {
//Move and scale down from right
currentFrame=1;
iTween.CameraFadeDestroy();
plane1.renderer.enabled=true;
iTween.MoveFrom(plane1,{
"x":55,
"time":fadeInTime,
"delay":1,
"easetype":"easeOutCirc",
"speed":slideSpeed,
"onComplete":"showPanel2",
"onCompleteParams":timePerFrame,
"onCompleteTarget":transform.gameObject
});
iTween.ScaleFrom(plane1,{
"x":5.7,
"y":3,
"z":4.4,
"delay":1,
"easetype":"easeOutSine",
"speed":scaleSpeed/2
});
}
function showPanel2() {
//Move away and scale down
currentFrame=2;
iTween.MoveTo(plane1,{
"x":-55,
"time":fadeInTime,
"delay":timePerFrame,
"easetype":"easeInCirc",
"speed":slideSpeed,
"onComplete":"fadeOut",
"onCompleteParams":0,
"onCompleteTarget":transform.gameObject
});
iTween.ScaleTo(plane1,{
"x":0,
"y":0,
"z":0,
"delay":timePerFrame,
"easetype":"easeInSine",
"speed":scaleSpeed*2
});
}
function fadeOut(tempDelay:float) {
currentFrame=3;
iTween.CameraFadeAdd();
iTween.CameraFadeTo({
"amount":1,
"time":fadeInTime,
"delay":tempDelay*2,
"onComplete":"endComics",
"onCompleteTarget":transform.gameObject
});
}
function endComics() {
Application.LoadLevel(Scenes.WORLD_MAP);
}
function getInput() {
if (canSkip==true) {
if (CursorUtils.hitState() == HitState.Down) {
skipComics();
}
}
}
function skipComics() {
switch (currentFrame) {
case 1 :
iTween.Stop(plane1);
plane1.transform.position=Vector3(0,0,0);
plane1.transform.localScale=plane1Scale;
timePerFrame=0.5;
showPanel2();
break;
case 2 :
iTween.Stop(plane1);
fadeOut(0);
break;
}
}
When I leave the animation to play without interrupting it with iTween.Stop() or iTween.StopByName() it works on the iPad. When I try to skip it sometimes just hangs and I recieve the following in Xcode:
(Filename: Line: -1)
NullReferenceException
at iTween.Stop (UnityEngine.GameObject target) [0x00000] in <filename unknown>:0
at iTween.Stop () [0x00000] in <filename unknown>:0
at ShaolinDepart_Comics01_Script.skipComics () [0x00000] in <filename unknown>:0
at ShaolinDepart_Comics01_Script.getInput () [0x00000] in <filename unknown>:0
at ShaolinDepart_Comics01_Script.Update () [0x00000] in <filename unknown>:0
..which I don't know what it means.
I use Unity 3.3 and Xcode 4.2.
Thanks for your help in advance and I need this ASAP. Thanks!
Your answer

Follow this Question
Related Questions
iTween can't access instantiated child. 1 Answer
iTween NullReferenceException error 1 Answer
Using iTween with a prefab tree. 0 Answers
iTween call producing NullReferenceException 3 Answers
iTween - Null Reference 0 Answers