Author Topic: Pushing sprites  (Read 11751 times)

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Pushing sprites
« Reply #15 on: 2009-09-17, 07:51:56 AM »
I totally convinced him to do dynamic sprites.  My bad! ;)
Edward Dassmesser

Vincent

  • SGDK2 Addict
  • Expert
  • Fanatic
  • *****
  • Posts: 612
  • Legacy of Kain: Revival is completed!!!
    • View Profile
    • Chivalrous Games
    • Email
Re: Pushing sprites
« Reply #16 on: 2009-09-17, 07:54:52 AM »
Ha ha!  :laugh:
Nothing to be ashamed about, dynamic sprites are useful! :)  In fact, I use them much more than "static" sprites.
Legacy of Kain: Revival completed!
http://lokrevival.webs.com

See also my company website:
http://chivalrousgames.com

Vincent

  • SGDK2 Addict
  • Expert
  • Fanatic
  • *****
  • Posts: 612
  • Legacy of Kain: Revival is completed!!!
    • View Profile
    • Chivalrous Games
    • Email
Re: Pushing sprites
« Reply #17 on: 2009-09-17, 11:09:40 AM »
Hi! 

I've got some problems managing static TKBolt sprites to achieve what the dynamic ones were doing.  Can someone help me out?  For dynamic sprites I used to do this:
(simplified version)
Code: [Select]
If throwing TKBolt
    SpawnTKBolt
    PushTKBolt in right direction
EndIf

Now, I'm managing a buffer of 3 static TKBolts (should be enough)
It looks like this:
Code: [Select]
If throwing TKBolt
    Verify which one is the next TKBolt to throw
    Select the proper TKBolt (With the SelectTargetSprite rule)
    SetTargetSpriteParameter (the X location)
    SetTargetSpriteParameter (the Y location)
    Activate the TKBolt Sprite      <---  There's the problem!
    ThrowTheTKBolt in the right direction
EndIf

Oh, I forgot to mention that these rules are included in Kain's sprite.  I don't want to create a plan for each map to manage the TKBolts.  If the code was included in Kain's sprite, it would be much simpler.

But there is no function to activate a sprite that was selected by the SelectTargetSprite rule...

As you can see, I never even got to testing this, because it is obvious it won't work without activating the TKBolt sprite.
I guess I will create a function, based on SetTargetParameter to activate a sprite...  Unless there is a better approach?  Is my logic OK?  Oh, and all of this started on the fact that I thing that SelectTargetSprite and SetTargetParameter actually work on a deactivated sprite...  Is it the case?

Thanks a lot! :)
« Last Edit: 2009-09-17, 11:15:11 AM by Vincent »
Legacy of Kain: Revival completed!
http://lokrevival.webs.com

See also my company website:
http://chivalrousgames.com

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Pushing sprites
« Reply #18 on: 2009-09-17, 02:33:17 PM »
1) I think you want to activate it before doing anything else to it because most rules will display an error message when running in debug mode if you try to do anything on a de-activated sprite (to help you make sure you're not running code unnecessarily on inactive sprites).
2) The code for ActivateSprite (in SpriteBase.cs) is very simple if I recall.  And the code for doing anything to the selected target sprite is very simple.  I bet you could make your own ActivateTargetSprite function by looking at the code for ActivateSprite and SetTargetSpriteParameter.  Or maybe SetTargetSpriteParameter can be used to activate a sprite by setting the "active" parameter to true?  (I don't have SGDK2 handy at the moment.)

Vincent

  • SGDK2 Addict
  • Expert
  • Fanatic
  • *****
  • Posts: 612
  • Legacy of Kain: Revival is completed!!!
    • View Profile
    • Chivalrous Games
    • Email
Re: Pushing sprites
« Reply #19 on: 2009-09-18, 11:27:51 AM »
Allright, I got it working today.  I wrote a small function like you said bluemonkmn.  It works well!

Thanks a lot!  ;D
Legacy of Kain: Revival completed!
http://lokrevival.webs.com

See also my company website:
http://chivalrousgames.com