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

Username:   Password: 
 RegisterRegister   
 Problem Viewing Sprites from One Window to Another Window
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
lmaria




PostPosted: Wed Jun 08, 2011 2:02 pm   Post subject: Problem Viewing Sprites from One Window to Another Window

What is it you are trying to achieve?
I am trying to use a sprite in multiple windows.

What is the problem you are having?
The sprite seems to load up and display in the first window of the program. But, once I advance to a second window, the sprite does not appear.


Describe what you have tried to solve this problem
I've tried: Freeing the sprite and reloading it. I've tried using different picture files for each window. I've tried setting the focus on the correct window.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing:


var mainWindow1, mainWindow2 : int  %Identification for two windows

var keyInput : string (1)   %To use with getch to flip windows

var bfly : int      %Butterfly sprite
var picID : int

%First Window
procedure first
    mainWindow1 := Window.Open ("title:The Butterfly-First Window;nocursor;noecho;position:center;top;graphics:400;300")

    put "Press ESC key to go to next window."

    picID := Pic.FileNew ("butterfly1.gif")
    bfly := Sprite.New (picID)
    Sprite.SetPosition (bfly, 100, 200, false)
    Sprite.Show (bfly)

    %Stay on window until ESC key hit
    loop
        getch (keyInput)
        exit when (ord (keyInput) = 27)
    end loop

    Sprite.Free (bfly)
    Pic.Free (picID)

end first

%Second window
procedure second

    mainWindow2 := Window.Open ("title:The Butterfly-2nd Window;nocursor;noecho;position:center;middle;graphics:400;300")
    Window.Close (mainWindow1)
    Window.SetActive (mainWindow2)
    Window.Select (mainWindow2)

    put "Press ESC key to go to end."

    %Reload the sprite with the picture
    picID := Pic.FileNew ("butterfly2.gif")
    bfly := Sprite.New (picID)

    Sprite.SetPosition (bfly, 50, 100, false)
    Sprite.Show (bfly)

    %Stay on window until ESC key hit
    loop
        getch (keyInput)
        exit when (ord (keyInput) = 27)
    end loop

    Window.Close (mainWindow2)
end second

% Main Body
first
second








Please specify what version of Turing you are using
Turing 4.1.1



butterfly1.GIF
 Description:
 Filesize:  2.18 KB
 Viewed:  1538 Time(s)

butterfly1.GIF


Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Wed Jun 08, 2011 4:12 pm   Post subject: RE:Problem Viewing Sprites from One Window to Another Window

Is there a butterfly2.gif, or did you intend to load bufferfly1.gif, and were a little too zealous changing "1" into "2"?
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  [ 2 Posts ]
Jump to:   


Style:  
Search: