One of those errors that I don't understand. I want enemies and the player to flash for a few frames whenever they get hurt. I used the hurt demo as a reference and pasted it into my vb6.0 project and changed all the variable names and made it universal to work on any sprite:
Public Sub DrawHurtTilesOverSprite(ByVal Spr As Sprite)
Dim TS As TileSetDef
With Spr
Set TS = ProjectObj.TileSetDef(.CurTSDef.GetIndex + 11) '11 being separation between corresponding tilesets
If Not TS.IsLoaded Then
TS.Load
End If
If TS.LoadedInstance Is Nothing Then
Set TS.LoadedInstance = DllDisp.CreateTileSet(TS.Image, TS.TileWidth, TS.TileHeight)
End If
DllDisp.DrawTile TS.LoadedInstance, .CurTile, .X - GdPlayer.MapScrollX, .Y - GdPlayer.MapScrollY, 0, 0, 640, 480, True
End With
End Sub
Sub Player_OnSpritesCollide(Name, ClsAIdx, ClsBIdx, CollDefIdx)
Hurt = 100
End Sub
Sub Player_OnBeforeMoveSprites()
Dim TS
If Hurt > 0 Then
Hurt = Hurt - 1
If Hurt Mod 2 = 1 Then
With ProjectObj.GamePlayer
Set TS = ProjectObj.TileSetDef("tsHurt")
If Not TS.IsLoaded Then
TS.Load
End If
If TS.LoadedInstance Is Nothing Then
Set TS.LoadedInstance = CurrentDisplay.CreateTileSet( _
TS.Image, TS.TileWidth, TS.TileHeight)
End If
CurrentDisplay.DrawTile _
TS.LoadedInstance, _
.PlayerSprite.CurTile, _
.PlayerSprite.X - .MapScrollX, _
.PlayerSprite.Y - .MapScrollY, _
0, 0, 640, 480, True
End With
End If
End If
End Sub
I have the hurt demo script on the bottom for reference. (I run my code every other frame if the sprite is hurt using the same event as the hurt demo)
my error message is :
Run-time error '-2147418113 (8000ffffy)'
Method 'Image' of object 'TileSetDef' failed
Everything seems to work good except any time I call TS.image, i get that error (i even put it in a line by itself) I've confirmed that TS.IsLoaded is True and TS.TileWidth has a value (32)
I even set the TS to a tileset I KNOW is loaded (the TS of the playersprite) and I still get the same error.
I've also tried breaking the lines into multipul lines and dimming the varibles different, but nothing seems to work. I see that .Image is actually a Property and not a Method like VB seems to think, maybe this is the problem, but I don't know how to fix it.
Anyone know what to do or try? ($50 says bluemonk posts with a brillant easy solution
)