[Bug?] Funny sprite behavior?

Post your own tutorials, guides and demos.

Post » Wed Jan 21, 2009 9:12 pm

Okay, I have attached a demo, which uses contained sprites and hashtables. By right clicking them, the hashtable value is incremented by one.

At 1 click the sprite turns green, next click it reverts to yellow. At 5 clicks it is destroyed.

Now, click around a bit and you might notice a funny behavior... Like, sprites start rebelling and changing color when they should not or even get destroyed en masse.

What gives? Is it a bug? If so, I'd like to pinpoint it down before submitting a report. If it is just sloppy programming on my part, I'd like to have the flaw pointed out.

Thanks! :)
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Wed Jan 21, 2009 9:36 pm

No I don't think it's a bug.

Just put the Sprite in the event sheet where you have the family green now and it should work.
The hashtable is in a container with the sprite, so it won't work the way you want it to when you're using the family this way.
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Wed Jan 21, 2009 9:47 pm

I see, makes sense now. I need to clear this up (among other things) before I attempt a real project, so I am making weird stuff like this to see how it works.

If I got it right, if I want to change a specific sprite, I should pick it singularly instead of the family, but where I need to address a number of sprites, I should use a family instead?
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Thu Jan 22, 2009 12:24 am

[quote="Mipey":2n03pgje]If I got it right, if I want to change a specific sprite, I should pick it singularly instead of the family, but where I need to address a number of sprites, I should use a family instead?[/quote:2n03pgje]

Not necessarily. Just because you have Sprite1 and Sprite2 in the Foo Family doesn't mean you have to pick Sprite1 by the family, nor does it mean you have to pick Sprite1 specifically in order to exclude Sprite2.

For example, Sprite1 and Sprite2 are both in the Foo Family. All Sprite1's have the value '1' in their 'myNum' variable, and all Sprite2's have '2' in their 'myNum' variable. You could pick all Sprite1's like so, if you wanted to:

[code:2n03pgje]
+ Foo.Value('myNum') is equal to 1
-> Do stuff to Foo
[/code:2n03pgje]

It all depends on what you need Construct to do.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Thu Jan 22, 2009 9:36 am

But what if you store values externally, say, from a hashtable, which is in a container with the sprite? Would the proper sprites be picked up by checking for hashtable key value?

As you can see, I used exactly that in the above example and it behaved funny if I picked families by contained hashtable values.

I want to use hashtable as I will need a dynamic table of variables, while there can be only a fixed number of PVs. Well, I could put numerous values into PVs as concatenated strings, but that'd make things unnecessarily complex (i.e. using Find() to locate the exact string in PV for each object would take more CPU time than just reading hashtable value).

Oh gee, am I complicating too much? I just want a sprite or some sort of object that represents a RPG character/NPC/enemy with lots of variables of varying amount... the system has to be very robust, if I get bugs like my huge male barbarian suddenly becomes a female gnome witch... well... that'd be fun, actually. :lol:
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155


Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 2 guests