Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 SPRITE Problems in my game, freed sprite problem.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
RyGuy-Anime




PostPosted: Tue Jan 24, 2012 3:20 pm   Post subject: SPRITE Problems in my game, freed sprite problem.

What is it you are trying to achieve?
A "Blast Attack to go across the screen.. this is my first attempt at a game btw

What is the problem you are having?
it says i freed my sprite but i cannot find any lines where i've done it

Describe what you have tried to solve this problem
Anything i could think of

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
process shoot
loop
location1 := locationx + 7
location2 := locationy + 10
%Sprite.SetPosition (lasersprite, location1, location2, false) %sets location vairables)
%Sprite.SetHeight (lasersprite, 3)
if blast = true then
if direction = 1 then
Sprite.Show (lasersprite)
loop
location1 := location1 - 7
Sprite.Show (lasersprite)
if location1 = a then
if location2 + 10 > b and location2 - 10 < b
then
hit := true
exit
end if
elsif location1 < -20 then
exit
end if

end loop
else
Sprite.Show (lasersprite)
loop
location1 := location1 + 7
Sprite.Show (lasersprite)
if room = 3 and location1 = a then
if location2 + 10 > b and location2 - 10 < b
then
hit := true
exit
end if
elsif location1 > 340 then
exit
end if
end loop
end if
end if
if ended = true then
%Sprite.Hide (lasersprite)
exit
end if
end loop
end shoot


Turing:




Please specify what version of Turing you are using
4.1.1



Treason.zip
 Description:
Here's the full game :/

Download
 Filename:  Treason.zip
 Filesize:  9.38 MB
 Downloaded:  106 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Dreadnought




PostPosted: Tue Jan 24, 2012 3:57 pm   Post subject: Re: SPRITE Problems in my game, freed sprite problem.

When you create a sprite it is associated with the window that was active at the time of its creation.

You may not realize it, but while you are loading sprites and pictures at the beginning of your program, the default window (window Id -1 I think) is considered active for Turing (even if you can't see it).

When you call the line
Turing:
setscreen ("graphics:400;330")

This creates a window that is different from the standard Turing window. So Turing creates a new window and closes the old one (even if you couldn't see it). And with closing that window all the sprites that were associated with it are freed.

A way of fixing this might be to place the setscreen statement earlier in the program or creating sprites later.

Hope this helps.
RyGuy-Anime




PostPosted: Tue Jan 24, 2012 7:05 pm   Post subject: Re: SPRITE Problems in my game, freed sprite problem.

Thanks a ton Very Happy although i find it weird since the rest of the sprites worked fine above the setscreen... I'd give you bits if i knew how Razz. When i finish the beta version of the game i'll post it if anyone is interested, the only thing i need left is to get the blast attack moving...
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: