Prowler Productions
  Dink Smallwood Forum
  A sprite that refuses to die

Post New Topic  
profile | register | faq

Author Topic:   A sprite that refuses to die
Tamtur posted 10-14- 04:28 PM CT (US)   Click Here to See the Profile for Tamtur   Click Here to Email Tamtur  
hey everyone

I have a hypothetical question. The below script is for a toggle button that redraws the button as a new sprite, deleting the previous button (so it changes from frame 11 to frame 12 and back). Obviously, this is the hard way to do things. I have since re-written it to simply change the current sprite's frame.

However, I am wondering why the script worked except for one thing - the original button, drawn with the editor, would not be killed by the second button sprite which is drawn when the first is clicked. All of the others would be killed once they'd drawn the new sprite, as dink ran the 'main' proc of the new sprite.

Does anyone know why the original editor-drawn sprite refused to die?

here is the script:

void main ( void )
{
sp_touch_damage(¤t_sprite,-1);
sp_brain(¤t_sprite,14);
wait(5);
sp_active (&2lang, 0);
//&2lang is a global variable
//it made no difference if the sp_active were here or
//at the end of the 'click' procedure
wait(1);
&2lang = ¤t_sprite;
}


void click ( void )
{
If (&lang == 1)
{
&lang = 2;
} else
{
&lang = 1;
}
int &xspot = 0;
&xspot = sp_x (&2lang, -1);
&xspot -= 10;
//I put the x change in to see if I was successful in
//killing the prev sprites
int &12temp = ⟨
&12temp += 10;
int &73temp = create_sprite (&xspot, 270, 14, 99, &12temp);
sp_script (&73temp, "language");
}

Tamtur posted 10-20- 03:07 PM CT (US)     Click Here to See the Profile for Tamtur  Click Here to Email Tamtur     
anyone?
FF4LIFE posted 10-21- 05:44 PM CT (US)     Click Here to See the Profile for FF4LIFE  Click Here to Email FF4LIFE     
So, you want it to look like something when you're on it and look different when you're off? Because if thats the case you just use this:

void buttonon(void)
{
sp_pframe(¤t_sprite, 12);
}
void buttonoff(void)
{
sp_pframe(¤t_sprite, 11);
}

reword what you wanted i'm slightly confused....

FF4LIFE posted 10-21- 05:48 PM CT (US)     Click Here to See the Profile for FF4LIFE  Click Here to Email FF4LIFE     
Oh ok, i know why it wouldn't die. I think... Ok, so you set the global equal to the sprite number you wanted to kill...then you in the next sprite used a sprite active(&global, 0);

Something like that? Because if you did, i don't think you can do that....use globals in the sp_active command. I'm pretty sure you can only use variables. So in the first one you could have a spawn(whatever) then put a kill_this_task(); or a current sprite no active...but i'm still really confused by your quesetion...ah well, maybe this rambling means something...

Tamtur posted 10-26- 02:01 PM CT (US)     Click Here to See the Profile for Tamtur  Click Here to Email Tamtur     
It's not just while the pointer is over the button - I want it to be a "toggle switch" - so, say, if it were an off-on switch they click it and the sprite reads "off", then next time they click it it will go back to "on" and so on. I changed the script to just be changing the frame of the sprite, but I am still curious why it wouldn't work.

I don't think it's for the reason you said, because it's only the first sprite that stuck around after I clicked it. When I click the sprite generated by the original sprite, it creates a third sprite and then is deleted; the third sprite created, when clicked, creates the fourth sprite and then is deleted - it's only the first sprite, placed by the editor, that doesn't die after creating the second.

The &2lang = ¤t_sprite line in the main proc should have taken care of the global equaling the editor-drawn sprite (&2lang isn't used in any other script right now), perhaps that is where the problem is? If it were the problem then the sp_active line wouldn't work on the first sprite.

Andrea

FF4LIFE posted 10-26- 04:07 PM CT (US)     Click Here to See the Profile for FF4LIFE  Click Here to Email FF4LIFE     
Ok, so have you already tried something like this:

void click(void)
{
&frame = sp_pframe(¤t_sprite, -1);

if (&frame == 11)
{
sp_pframe(¤t_sprite, 12);
return;
}
if (&frame == 12)
{
sp_pframe(¤t_sprite, 11);
return;
}

}

I'm not sure if this is what you've already tried and had it not work...if this doesn't work then i'm really stumped...this just makes the most sense.

Tamtur posted 10-27- 02:12 AM CT (US)     Click Here to See the Profile for Tamtur  Click Here to Email Tamtur     
Yeah, that's what I've done, and it does work... I'm just asking as a hypothetical question since there is a different part of my program where I will probably want to delete a sprite with a sprite it created. I'd probably use a very similar script to this one if I could get it to work properly.
FF4LIFE posted 10-27- 02:42 PM CT (US)     Click Here to See the Profile for FF4LIFE  Click Here to Email FF4LIFE     
Well, I sort of have to do that at one point, and i did think about setting a global to the sprite number, and i think i found out it works with a little work. If you put this in the first sprite:

int &crap = sp(¤t_sprite);
&global = &crap;

and this in the second sprite:

int &crap = &global;
int &sprite = sp(&crap);
sp_active(&sprite, 0);

that should work, maybe you could even just do:

int &sprite = sp(&global);
sp_active(&sprite, 0);

but i have a feeling that you can't use the global in there...but maybe, try it. The way i do that now...well actualy i don't do it anymore... For my status screen i just spawn the button that you click to get it to dissapear and off that spawn everything else, then when i click it i just put a lot of sp_active's for other sprites and then for itself. But this method should work if you ever need to use it.

Tamtur posted 10-27- 02:54 PM CT (US)     Click Here to See the Profile for Tamtur  Click Here to Email Tamtur     
What's wierd is that it worked with the global in sp_active in all the sprites except the second one, which didn't delete the original. I think I'll add a couple lines just for the first sprite, to make sure it knows the number.
(BTW, all of the sprites have the same script for my purpose)

Thanks for the help

FF4LIFE posted 10-28- 01:57 PM CT (US)     Click Here to See the Profile for FF4LIFE  Click Here to Email FF4LIFE     
So, you're spawning a bunch of sprites that look the same and just kill the previous sprite instantly? Why don't you just have one sprite and change its coordinates?

Post New Topic  Post Reply
Hop to:


Contact Us | Prowler Productions

Powered by: Ultimate Bulletin Board, Freeware Version 5.10a
Purchase our Licensed Version- which adds many more features!
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 2000.