Scrolling Game Development Kit Forum

SGDK Version 2 => Help, Errors, FAQ => Topic started by: Tanja on 2008-08-22, 02:26:49 PM

Title: attempted to access ... on inactive sprite
Post by: Tanja on 2008-08-22, 02:26:49 PM
hi there,
my player drops seed when a button is pressed. if the seed touches the ground, it can be collected again. that works wonderful all the time, as long no one drops more than one seed in one spot. than this message comes  "attempted to access PixelX on inactive sprite". the seed sprite has some rules, they are very simple. after be touched the sprite is deactivated. so i don
Title: Re: attempted to access ... on inactive sprite
Post by: bluemonkmn on 2008-08-23, 08:23:00 PM
I can't guess why you would have an inactive sprite problem only when there are two in the same place.  I guess I would need to see more of the code, or know more about where the error occurred.  If you have C# installed, maybe you could run it in a debugger to find out more detail about where the error happened.  If you run the project in debug mode from SGDK2, does it tell you more about the code where the error occurred?

IsKeyPressed doesn't support "InitialOnly"; only the controller inputs can return information about whether this is the first press because they are the only buttons that are tracked.  In order to determine if some random key was pressed before, all keys on the keyboard would have to be tracked.  But they are not being tracked.  The intention is that games only deal with controller inputs, so they are supported better than arbitrary keypresses.
Title: Re: attempted to access ... on inactive sprite
Post by: Jam0864 on 2008-08-24, 02:22:06 AM
couldn't you just stop two being in the same place, if one seed touches other seed, delete the seed and give it back to the players inventory.
Title: Re: attempted to access ... on inactive sprite
Post by: Tanja on 2008-08-24, 12:36:40 PM
the game was running now for two days at the games convention in Leipzig. i wasn
Title: Re: attempted to access ... on inactive sprite
Post by: bluemonkmn on 2008-08-25, 05:11:48 AM
I doubt that it's a hardware/environment difference.  That error is pretty specific to SGDK2 code.  It's probably just a specific use that didn't get hit in those 2 days.

(Has the game been posted for public download anywhere yet?)

Weird coincidence: Looks like Jam0864 and Tanja reached 500 posts at the same time!

(Edit - 2 spelling corrections)
Title: Re: attempted to access ... on inactive sprite
Post by: Jam0864 on 2008-08-25, 05:53:26 AM
wow that is weird LOL
Title: Re: attempted to access ... on inactive sprite
Post by: Tanja on 2008-08-25, 06:12:07 AM
hehe, funny coincidence.  8) yay 500!
i want to provide the game in the next few days. but it is far from being finished, in my opininion. but a lot of kids liked it much anyways.
Title: Re: attempted to access ... on inactive sprite
Post by: durnurd on 2008-08-25, 07:46:49 AM
I imagine BlueMonk is asking because if it were available, he could take a look and see where the problem might lie, whether it's a bug in SGDK2 or just an overlooked use-case in the programming that wasn't taken care of.
Title: Re: attempted to access ... on inactive sprite
Post by: Tanja on 2008-08-25, 08:31:24 AM
i know, i just want to fix a few thing before i give it away.
Title: Re: attempted to access ... on inactive sprite
Post by: Tanja on 2008-08-26, 10:59:31 AM
IsKeyPressed doesn't support "InitialOnly"; only the controller inputs can return information about whether this is the first press because they are the only buttons that are tracked.  In order to determine if some random key was pressed before, all keys on the keyboard would have to be tracked.  But they are not being tracked.  The intention is that games only deal with controller inputs, so they are supported better than arbitrary keypresses.

okay, wouldn
Title: Re: attempted to access ... on inactive sprite
Post by: durnurd on 2008-08-26, 08:17:28 PM
My first suggestion to you is to use the inputs instead, just map the particular key you're using to the default value for a button in the controls you aren't using (Look in Controls.cs).  That is the suggested way of getting input from the player, since the player can then customize the controls.

However, if you have only one place that this key is used, and it's a special case, or you just don't have any inputs left in the controls, or you have some other reason you want to use IsKeyPressed, you can make up your own "InitialOnly" manually.

I'm assuming these rules are being executed on a sprite.  First, create a property on the sprite called wasPressed.  Then create this control structure using the rules:
Code: [Select]
if IsKeyPressed(your key)
  if wasPressed == 0
    (Do whatever you want to do)
  end if
  wasPressed = 1
else
  wasPressed = 0
end if
Title: Re: attempted to access ... on inactive sprite
Post by: Tanja on 2008-08-27, 07:52:19 AM
thanks, that must work! i love the sprite parameters, first i tried to do all with counters, that was confusing.

@bluemonk: take a look at my last post here, there is supposed to be more text. i hope this happens not everywhere. why are we moving?
Title: Re: attempted to access ... on inactive sprite
Post by: bluemonkmn on 2008-08-27, 11:06:52 AM
Looks like the SMF backup procedure didn't escape German single-quotes (???).  That's really odd.  My single quotes are OK, but yours aren't.  Your client must have been submitting apostrophes with a different code somehow.  That sounds like a serious potential security breach in SMF.

We're moving so that I have the forums on a server I control and Pr0c doesn't have to maintain a running database (server) just for my forum.
Title: Re: attempted to access ... on inactive sprite
Post by: Tanja on 2008-08-27, 11:53:15 AM
i used an accent instead of an real apostroph, i think. like in
Title: Re: attempted to access ... on inactive sprite
Post by: bluemonkmn on 2008-08-28, 04:43:45 PM
Woohoo -- fixed it.  :nerd:
(I don't know what happened here (http://gamedev.enigmadream.com/index.php?topic=772.0) though.  Did that one ever look any better?)
Title: Re: attempted to access ... on inactive sprite
Post by: durnurd on 2008-08-28, 08:27:40 PM
At some point, it must've.  I don't remember what was there before, though.
Title: Re: attempted to access ... on inactive sprite
Post by: Tanja on 2008-08-29, 01:35:09 AM
i'm glad the lost part of my message wasn't lost forever. phew.
Title: Re: attempted to access ... on inactive sprite
Post by: Tanja on 2008-09-04, 06:54:02 AM
strange. a new "attempted access"-message at another project. i have some moving sprites, after going too far outside the map they shall be deleted (insert evil laugh)
i made this little code at the bottom of the sprite rules:
Code: [Select]
// if out of map
         if ((((x) <= (-200))
                  || ((x) > (6500))))
         {
            // deactivate
            this.Deactivate();
         }
i believe at my computer at home this worked, but now on my friends computer not?! i've uploaded the "birdies"-file to the support site, bluemonk. hopefully you can find something.
Title: Re: attempted to access ... on inactive sprite
Post by: bluemonkmn on 2008-09-04, 05:14:00 PM
This is a problem that was pointed out to me by Durnurd and has been fixed in 2.1, but not released yet.  The problem is in TextCollisionRect in SpriteBase.cs.  To fix it you just have to change one line:
Code: [Select]
if (TargetSprite == this)
should be
Code: [Select]
if ((TargetSprite == this) || (!TargetSprite.isActive))
Title: Re: attempted to access ... on inactive sprite
Post by: Tanja on 2008-09-05, 03:05:14 AM
wheeeee! thanks!