Posted: 4th Sep 2011 10:47
Hi, thanks to G T R i got the AppGameKit player working for my iPod touch... It works grate but some sprites won't load.

In the game im making, you are supposed to fly a helicopter and defend a island against enemy ships. But the island won't load. I tried to check if the sprite exists and if it dons't go back to loading the island again but for some reason the helicopter sprite turns into the island... An other strange bug I get is that each time I load the game onto my iPod the player says that the last error I got was that a sprite dosn't exist but the sprite isn't the same evry time...

+ Code Snippet
SetRandomSeed ( timer ())
//used to store all variables for the enemies
Type Enemy
    ID as integer
    AtIsland as integer
    Health As Float
    X as float
    Y as float
    Angle As Float
    DistanceXY as float
    DistanceX as Float
    DistanceY as float
    DirectionX as float
    DirectionY as float
endtype

//Storing Variables for all weapons
Type Weapon
    ID as integer
    Damage as Float
    X as float
    Y as Float
    Angle as Float
EndType

Type XY
    X as float
    Y as float
endtype

Type Score
    ShipsAtIsland
    Kills
    Damage
endtype

//Creating score variable
Score As score
//Creating the distance array
Dim Distance[10] as XY

rem Landscape App
SetDisplayAspect( 4.0/3.0 )

//*****Loading The background*****
//Creating the sea
Sea = LoadImage("sea.png")
CreateSprite(Sea,Sea)
SetSpriteDepth (Sea , 1000)

//Creating the island
Island = LoadImage("Island1.png")
CreateSprite(Island)
SetSpriteShape(island,3)
SetSpriteDepth (Island , 999)



SetSpriteScale(island,0.05,0.05)
SetSpritePosition(Island,30,30)

//*****Loading the player*****
Player=LoadImage("Cobra.png")
CreateSprite(Player,Player)
SetSpriteDepth (player, 2)

SetSpriteScale(player,0.015,0.015)


//*****Hellfire*****
//Loading the target sprite


TargetMark = LoadImage("TargetMark.png")
CreateSprite(TargetMark,TargetMark)

SetSpriteScale(TargetMark,0.05,0.05)
SetSpriteVisible (TargetMark,0)

//Place the target above the other sprites
SetSpriteDepth(TargetMark , 1)

//Creating Creating The Missile
//Using Target Mark For now
Hellfire as weapon

Hellfire.ID = LoadImage( "targetMark.png" )
CreateSprite (Hellfire.ID , Hellfire.ID)

SetSpriteScale (Hellfire.ID,0.05,0.05)
SetSpriteVisible (hellfire.ID,0)

//*************************************************
//Loading all enemies

//Creating the array
Dim Enemies[10] as Enemy

enemy = LoadImage ("Ship.png")
//Loading the image
For i=1 to 10
    enemies[i].ID = CreateSprite(enemy)
    SetSpriteScale(enemies[i].id,0.05,0.05)
    SetSpriteShape(enemies[i].id,3)
next i
//********************************


That's all the code that loads sprites...
Posted: 4th Sep 2011 15:48
Why do you jump from lower case to upper case???
I know AppGameKit allows it, but it makes the code look sloppy.
Variable names like NAME Name and name are all the same but files may not work like that...
TargetMark = LoadImage("TargetMark.png")
Hellfire.ID = LoadImage( "targetMark.png" )

Maybe it can't load TargetMark.png, so that image ID remains a value of zero.
Then if you CreateSprite(0,whatever) it crashes, because...
"You may use an image ID of 0 to create a blank sprite drawn with color only. "

Just a thought.
Posted: 4th Sep 2011 20:50
I found the problem, turns ot I had written CreateSprite(island) instead of CreateSprite(Island,Island). It worked on the PC but on the Ipod LoadImage and createSprite returned diffirent variables...

BTW Targetmark wasn't the sprite that didn't work...