Author Topic: Check which Sprite is PlayerSprite  (Read 2793 times)

gila kid

  • Visitor
  • *
  • Posts: 4
    • View Profile
    • http://www.freewebs.com/public_coolness.htm
Check which Sprite is PlayerSprite
« on: 2005-10-07, 01:52:40 PM »
Hello. I am writing a script so that I can switch the playersprite to an animated sprite. The animated sprite is player_strike and the original sprite is player

So taht when you press button1 you see him swing his sword. I hope I make myself clear?

But everytime I press button1 it makes a new player_strike sprite. This is because of my .removesprite method call. It removes I believe the (0)indexed sprite from the layer.

I want to execute my If then(oldAction NewAction and action button 1 statement based on which sprite is the player sprite.
If it is player, then it wille execute. If it is player_strike I don't want it to execute until I change the playersprite back to player. I havn't coded the back player script yet.

'How do I check to see which sprite is the playersprite?
'I tried to use an If then statement,
    If ProjectObj.GamePlayer.PlayerSprite = _
  ProjectObj.GamePlayer.rMap.rDef.SpriteDefs_("Player")  Then blah blah.......
End If

I also was wondering how to index it to (0) when I change back to "player" as the playersprite. So that in my code .RemoveSprite(0)(whenever I change to "player_strike") will work. Because obviously if I change back to my playersprite and do not index it to (0). Then it will not work.

One reason why I am changing sprite is because I don't want the main player to move while attacking. That is why I use to different sprites.
Gila Kid
(Halo 2 Xbox Gamertag)

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Check which Sprite is PlayerSprite
« Reply #1 on: 2005-10-07, 10:24:51 PM »
Could you just do this?
Code: [Select]
If ProjectObj.GamePlayer.PlayerSprite.rDef.Name = ProjectObj.GamePlayer.rMap.PlayerSpriteName Then ...

There is no easy way to put it at index 0.  If you want to remove the player sprite, just look through the list to find which one is the player sprite:
Code: [Select]

Dim Idx
Dim PlayerSpr
Set PlayerSpr = ProjectObj.GamePlayer.PlayerSprite
For Idx = 0 To PlayerSpr.rDef.rLayer.SpriteCount - 1
   If PlayerSpr.rDef.rLayer.Sprite(Idx) Is PlayerSpr Then Exit For
Next
PlayerSpr.rDef.rLayer.RemoveSprite(Idx)


But if you just want to switch sprites, the easiest thing would be to create a special function that is of type Switch To Sprite, and call that from script

gila kid

  • Visitor
  • *
  • Posts: 4
    • View Profile
    • http://www.freewebs.com/public_coolness.htm
Check which Sprite is PlayerSprite
« Reply #2 on: 2005-10-08, 07:53:07 AM »
Alright kool, thanks man
Gila Kid
(Halo 2 Xbox Gamertag)