Alright, I'm having more script problems. We have our player throwing a spear at an enemy. There's a collision between the two sprites, and I want to activate a function in script that will create a death animation sprite based on the enemy that was killed. Here's what I've got:
Dim SprDead
Sub Player_OnSpritesCollide(Name, ClsASprIdx, ClsBSprIdx, CollDefIdx)
Dim SprA, SprB
Set SprA = ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer.Sprite(ClsASprIdx)
Set SprB = ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer.Sprite(ClsBSprIdx)
If CollDefIdx = 1 Then
If left(SprB.rDef.Name, 4) = "Slug" Then
KillSprite (ClsBSprIdx)
End If
End If
End Sub
Function KillSprite (SprDead)
Dim X, Y
Dim NewSpr, Lyr
X = SprDead.X
Y = SprDead.Y
Set Lyr = ProjectObj.GamePlayer.rmap.MapLayer("Main")
Lyr.RemoveSprite SprDead
If left(SprDead.rDef.Name,4) = "Slug" Then Set NewSpr = Lyr.pMap.SpriteDefs("Dead_Slug_" + MapNum).MakeInstance
Lyr.AddSprite(NewSpr)
NewSpr.X = X
NewSpr.Y = Y
End Function
I get an error message saying "Object required: SprDead." From what I understand, it should have the value from where I pass it to the function. What's the deal here?