Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Strange Sprite BUG : Sprite 12 doesnt exist

Author
Message
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 24th Jan 2013 04:15 Edited at: 24th Jan 2013 04:35
TIER 2 - XCode 4.5 - AppGameKit 1076
It's very strange...



This is my 5 sprites for the fireworks when the slot do a big win.
The 1st sprite get stucked at the same position.
The 2nd sprite ID is always 12, even if i change the position in the code so where to create it.
The others work as expected.

When CreaSprite (in english CreateSprite) return the ID, it is not 12, but the real ID so 10120 (for example)

I don't understand why later in the animation update it get 12!!!!
I'm going crazy!!!
Why 12??????



Anyone encountered this problem?

In the while i'm testing other solutions...

Long life to Steve!
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 24th Jan 2013 07:44
Could you perhaps show us your Fire's class/struct?
I'd also like to see whether Fire is a table or other object (vector perhaps?). So, if you can, please show how you initialize Fire aswell.

Also, I guess that the 2nd snippet occurs on loop, many times, whereas initializing fire happens once. It could be that something else's changing their values.

Two possible options:
a) Something else changes their values
b) Something's wrong with your class and you need to make a list/table/vector of pointers

Follow me on twitter! @MotionStruct
Motion Struct blog
tornado
19
Years of Service
User Offline
Joined: 21st Jul 2005
Location:
Posted: 24th Jan 2013 08:54
xGEKKOX, take a closer look at [w] value: if it goes out of bounds set in structure (eg [6] while you have max of [5] in declaration), it will return the wrong value but not null. Just a suggestion.

Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 24th Jan 2013 09:08
I think he's using the array class so he should be safe with w < Fire.size().

What comes after your animation code?

xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 24th Jan 2013 15:48
The first firework only explode, the second never come out (the one with 12), the others work normally as...
They come up from the ground, reach the count when they need to explode and explode well.

The array is a vector:
struct _Fire { int id_sp; int oy; int conto; int cy; int fr; int anim; int vel; };
vector <_Fire> Fire(5);

The strange thing, is that the fireworks only worked 3/100 times, doing nothing!!!!

Long life to Steve!
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 24th Jan 2013 16:16
Oh my god, if i launch the fireworks immediately, they work.
If i initialize them after the slot init and the other sprite init, they don't work.
Investigating...

Long life to Steve!
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 24th Jan 2013 16:56
Can you show the CreaSprite function?

This might help with knowing how the sprite is being created.

Also, you are using integer values as the Y value passed into SetSpriteY. That function takes a float value for the Y value. This may or may not be having an undesired effect.

And some questions about the following code:


It is possible that both of the following will evaluate to true "if(Fire[w].anim == 0)" and "if(Fire[w].anim == 1)" in the same for loop iteration. This might happen because the anim value is set to one if this test fails "if(Fire[w].cy < Fire[w].conto)".

And, how are you setting the variable 'fps' used in this test "if(fps % 5 == 0)"? Frames Per Second is a floating point value as returned by ScreenFPS and used in SetSyncRate. The way you are using the variable makes it an integer. Assuming that is what you meant, try putting parenthesis around 'fps % 5' to make sure it is being parsed correctly.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 24th Jan 2013 19:49
I will post all in few minutes, cause now i changed something and now happen another thing ahaaha...
Thx for the help Lady.

Long life to Steve!
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 24th Jan 2013 20:07
This is part of my Manager


And this is the new version of fireworks...


And the vector now is...


Ok now the fireworks don't fire the 12 sprite doesn't exist, but now only 1 fire go over the max count!!!
Ahahah make me crazy!

Long life to Steve!
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 24th Jan 2013 22:22
Try changing this: if(_fuochi && fps % 2 == 0)
to this: if(_fuochi && ((fps % 2) == 0))

In theory, assuming normal precedence, your code should produce what you intend, but I never assume that compilers really do that.

Plus, it makes it much more readable and easier for a human being to parse.

And I just found a page that says the order of evaluation (at run time) is not necessarily the same order as the compiler uses.

All of your sprite ids are in the range of 10000 or more because you are using the automatic id generation version of CreateSprite.

And I am still quite suspicious of your use of integers for X and Y values instead of the floats used by the AppGameKit function and your own CreaSprite function.

Is your fps variable a float or integer and how are you setting it?

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 25th Jan 2013 02:22
The fps is an int.
For fps i never had problems, cause is an integer that do ++ on the loop function.
When arrive at 10000 return to 1.

I think is the float VS int as you said.
Now the ID problem is solved, but the coordinate still exist.
I wanna investigate on the compiler as you said.

Long life to Steve!
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 25th Jan 2013 04:15
Well incredible again....
All is solved creating and deleting the sprite each time i need fireworks.
But is strange, maybe the mistake is on other sprites.

I will post something if i understand better.

Long life to Steve!

Login to post a reply

Server time is: 2024-11-24 05:40:19
Your offset time is: 2024-11-24 05:40:19