- Home /
IOS animations don't always play on device..
Problem with 2D Toolkit when running on IOS device, sometimes, randomly, animations won't play and i will get an error (posted at the bottom), sometimes it works, sometimes it doesn't. obviously something to do with my array, or 2dtoolkit itself.. but the animations ALWAYS play on the mac, just sometimes they don't on the device..
Edit : This is the script that I'm having problems with:
var splatOne : GameObject;
var splatTwo : GameObject;
private var splats : GameObject[];
private var sound : AudioClip[];
var sound1 : AudioClip;
var sound2 : AudioClip;
var sound3 : AudioClip;
private var buttonPressed : boolean = false;
function Start (){
splats = new GameObject[2];
splats[0] = splatOne;
splats[1] = splatTwo;
sound = new AudioClip[3];
sound[0] = sound1;
sound[1] = sound2;
sound[2] = sound3;
}
function Update(){
StopRigid();
var randomSound = sound[Random.Range(0, sound.length)];
for (var evt : Touch in Input.touches) {
var quitOn = quit.HitTest(evt.position);
var retryOn = retry.HitTest(evt.position);
if (next){
var nextOn = next.HitTest(evt.position);
}
if (evt.phase == TouchPhase.Began) {
if (quitOn){
if (!buttonPressed){
var splatNumQuit = splats[Random.Range(0, splats.length)];
if (this.gameObject.name == "Win Menu(Clone)001"){
PoolManager.Pools["Bloods"].Spawn(splatNumQuit.transform, Vector3(0.6207508,1.584467,-4), Quaternion.identity);
AudioSource.PlayClipAtPoint(randomSound, quit.transform.position);
buttonPressed = true;
}
if (this.gameObject.name == "Lose Menu(Clone)001"){
PoolManager.Pools["Bloods"].Spawn(splatNumQuit.transform, Vector3(0.7495953,1.584468,-4), Quaternion.identity);
AudioSource.PlayClipAtPoint(randomSound, quit.transform.position);
buttonPressed = true;
}
Quit();
}
}
if (retryOn){
if (!buttonPressed){
var splatNumRetry = splats[Random.Range(0, splats.length)];
if (this.gameObject.name == "Win Menu(Clone)001"){
PoolManager.Pools["Bloods"].Spawn(splatNumRetry.transform, Vector3(1.207713,1.555835,-4), Quaternion.identity);
AudioSource.PlayClipAtPoint(randomSound, retry.transform.position);
buttonPressed = true;
}
if (this.gameObject.name == "Lose Menu(Clone)001"){
PoolManager.Pools["Bloods"].Spawn(splatNumRetry.transform, Vector3(1.594249,1.584468,-4), Quaternion.identity);
AudioSource.PlayClipAtPoint(randomSound, retry.transform.position);
buttonPressed = true;
}
Retry();
}
}
if (next){
if (nextOn){
if (!buttonPressed){
var splatNumNext = splats[Random.Range(0, splats.length)];
PoolManager.Pools["Bloods"].Spawn(splatNumNext.transform, Vector3(1.737412,1.584467,-4), Quaternion.identity);
AudioSource.PlayClipAtPoint(randomSound, next.transform.position);
buttonPressed = true;
Next();
}
}
}
}
}
}
NOTE: The script WORKS! on the mac, there are no errors, i found with xCodes internal profiler that whenever i click the button and the graphic doesn't show the following error occurs:
IndexOutOfRangeException: Array index is out of range. at tk2dSprite.Build () [0x00000] in :0 at tk2dSprite.GetCurrentVertexCount () [0x00000] in :0 at tk2dBaseSprite.set_spriteId (Int32 value) [0x00000] in :0 at tk2dBaseSprite.SwitchCollectionAndSprite (.tk2dSpriteCollectionData newCollection, Int32 newSpriteId) [0x00000] in :0 at tk2dAnimatedSprite.SetFrame (Int32 currFrame) [0x00000] in :0 at tk2dAnimatedSprite.Update () [0x00000] in :0
I know that the problem lies within THIS script, and i just can't find a solution, am i missing something? bearing in mind the problem occurs only on the iPad?
Will give it a go, not sure that will sort the array exception problem out though.
nope, although i suppose it does help to optimise my script. thanks anyway.
Answer by ratboy · Jul 29, 2012 at 11:58 AM
must have just been a build issue. i think i restarted everything, cleaned the ipad, maybe even reinstalled tk2d.. just one of those things.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
2d animation import 1 Answer
Animation in Unity 4.3 0 Answers
Some animations not looping how I want 1 Answer
Animating a cubemaps orientation 1 Answer