Scrolling Game Development Kit Forum

SGDK Version 2 => Help, Errors, FAQ => Topic started by: Tanja on 2007-11-28, 05:23:01 AM

Title: parent/child sprites
Post by: Tanja on 2007-11-28, 05:23:01 AM
my player carries a bag which is an extra sprite. is there an easy way to say: the bag is a child sprite, so it moves exactly like its parent? even if the parent is blocked by a wall, the child is also blocked, despite there is no touching of child collision rec and wall.
Title: Re: parent/child sprites
Post by: bluemonkmn on 2007-11-28, 07:41:21 AM
If you create a Plan, you can add a rule to the plan using the "MatchSpritePosition" function to make a sprite be in the same location as another sprite.  It is only available for plans because a bag sprite (for example) can't know which sprite is the player sprite for the current map.  Only a plan knows which sprites are on the current map.  (In the future I may be able to do something like "SetTargetSprite" to allow sprite rules to also refer to specific sprites, though.)

Does this help?
Title: Re: parent/child sprites
Post by: Tanja on 2007-11-28, 07:54:31 AM
it works, it works! YEAH!!
this is really cool....
(often i forgot to look what other methods are available for plans. i sought hardly for it at the sprite definitions)

i look forward to a "setTargetSprite" because it is coincidence that the parent sprite is the player in my game.
Title: Re: parent/child sprites
Post by: Tanja on 2007-11-28, 04:34:30 PM
and is there a method for UNmatching the position? like giving control of position back to the sprite itself?
i need to let go of the bag.

edit: oops. yet it works.
here is the plan rule: if Counter == 0, matchSpritePosition.
(when the player hits Button1, the Counter increments and stops. that would mean "let go of the sprite", since it is a "else" condition.  i thought that would work, but it only works if i define a Button1. when i say "if key rightShift is pressed" instead of Button1, the bag will move a little bit and then stop. curious thing, isnt it?)
Title: Re: parent/child sprites
Post by: bluemonkmn on 2007-11-28, 09:52:22 PM
I don't quite understand what you did or if it worked.  Do you still have a problem with dropping the bag?  Have you tried to use LogDebugValue to work it out?
Title: Re: parent/child sprites
Post by: Tanja on 2007-11-30, 03:19:11 PM
it is working now.
i use the log debug methods quite often to figure things out.
forget the blabla above. ;D