Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 5 Interaction: Events and Event Handling.

Similar presentations


Presentation on theme: "Chapter 5 Interaction: Events and Event Handling."— Presentation transcript:

1 Chapter 5 Interaction: Events and Event Handling

2 The area indicated below contains what? A.My First Method because that’s what is always done first B.An event -- a mouse click or key press C.An event handler method D.A parameter

3 How can parameters affect an event handler? A.They can allow it to vary the action based on the parameter value B.They can let you do more than one thing in the action C.They can let you click on an object to control the action

4 Building my OWN flight simulator: What will the plane do when the right arrow button is pushed? A.Turn left B.Turn right C.Alice will complain that there is a logic error D.I don’t know

5 Chapter 5: Interactive Worlds with Event Handling Instead of having “animation” controlled by a specific method (every time) – like my first method – Control can vary based on a set of possible “events” – Create an event link to a method – Multiple methods can link to same event – but perhaps with different parameters What code runs when you hit play? – Essentially a method “listening” for you to click or push a button – it listens over and over again

6 Identify the parameters in the following event link 1 IceSkater 2 kick3 iceSkater. rightLeg 4 iceSkater.rightLeg. lowerLeg.foot AXXXX BXXX CX DXX

7 Whoever is clicked on should “go” Suppose we have a world where the same thing should happen to whatever object – when we click on it. Suppose we have a game where whatever object is clicked on should – Turn to face an object (say a flower) – Then jump over it We’ll discuss two ways to do it – The second one is better.

8 Either the monkey or the hare jumps over the flower

9 Let’s see what that looks like

10 One way to set up the events is… But is there a better way?

11 Is there a better way? A.No, this is as good as it gets, because you need to be able to have a different parameter to the jump method, depending on who you click on B.Yes, I can tell you one…

12


Download ppt "Chapter 5 Interaction: Events and Event Handling."

Similar presentations


Ads by Google