Jump to content

Sanity check/question about a lesson...


Wolfsong
 Share

Recommended Posts

For this lesson here:

http://www.leadwerks.com/werkspace/page/tutorials/_/loops-r17

 

I want to see if I'm understanding something right. Though the lesson is about loops (which I do understand) I'm particularly interested in the bits about creating a Window and then a Context (which I'm not sure I understand).

 

------------

 

--Create a window

window = Window:Create()

 

--Create a rendering context

context = Context:Create(window)

 

--While loop

while window:KeyHit(Key.Escape)==false do

 

--Set the drawing color and clear the screen

context:SetColor(0,0,0)

context:Clear()

 

--Set the drawing color and blend mode

context:SetColor(1,1,1)

context:SetBlendMode(Blend.Alpha)

 

--Draw some text onscreen

context:DrawText("PRESS ESCAPE TO END THE PROGRAM.",2,2)

 

--Update the screen

context:Sync()

end

 

---------------

 

So, in this example, are we creating a Window which is then identified as 'window' - and then the Window ('window') is being assigned as the Context or "focus" of the following instructions?

 

So, using 'context:SetColor(0,0,0) would be the same as using window:SetColor(0,0,0)?

 

Am I understanding that right?

 

If so (or even if not), why would the line:

while window:KeyHit(Key.Escape)==false do

 

not be:

while context:KeyHit(Key.Escape)==false do

 

?

 

Or is hitting the Escape Key something that can only refer directly to 'window' as that relates directly to the actual Window, and not to 'context', since that relates to the variable 'window'?

 

Hopefully I explained that well lol.

 

 

Anyway, thanks!

 

Edit: Tried to place the code inside Code tags, but it ended up adding a ton of color tags.

Edited by Wolfsong
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...