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 / Problem adding animated sprite

Author
Message
DennisW
16
Years of Service
User Offline
Joined: 15th Jun 2008
Location: Ohio
Posted: 17th Jan 2012 11:13
I have a problem with putting in a animated sprite as shown in the code. I have other sprites in and working but now as the project gets larger it will not take any more animated sprites. When it gets to the setspriteanimation line I get error sprite dose not exist. It will create the sprite just if I add that line it quits. I have tried to delete a sprite then add a new one. That also dose note work. In searching I found where Rich had a problem close to this but I don't know if he found a answer. Anybody have this problem.



Ham and Eggs Breakfast
The Chicken was involved the Pig was Committed
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 17th Jan 2012 11:40
When you use the createsprite() command in that fashion don't you need it to store it in a variable as it returns the sprite number? E.g

Spr = CreateSprite(newmissile)

anwserman
13
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 17th Jan 2012 11:41 Edited at: 17th Jan 2012 11:42
Your code is wrong! That's why it isn't working. =) When you use "CreateSprite" with one parameter, you get an integer with the created sprite index. You're not catching this index, so that's why it is screwing up.

(Btw, be more specific with the naming of variables. 'newmissile' is not descriptive in the least. to be frank, it sucks! Do 'newMissileImage' and 'newMissileSprite' for instance, and then you can disconcern them apart when creating stuff )

Try this code on for size:


EDIT:
Yes Hodgey you are correct, when using that form you need to catch the return value.

Hi there. My name is Dug. I have just met you, and I love you.
DennisW
16
Years of Service
User Offline
Joined: 15th Jun 2008
Location: Ohio
Posted: 17th Jan 2012 12:09
Ok I see what I am doing wrong. It works like a champ. Thanks for the help anwserman and Hodgey

Dennis

Ham and Eggs Breakfast
The Chicken was involved the Pig was Committed
anwserman
13
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 17th Jan 2012 12:36
No problem! That's what we are here for! =) Like I said, just try to be more specific with your variable names - it will certainly help a lot when it comes to debugging bigger projects.

Hi there. My name is Dug. I have just met you, and I love you.

Login to post a reply

Server time is: 2024-11-26 13:14:09
Your offset time is: 2024-11-26 13:14:09