Moving Objects. Objectives You will know …  the Stage default dimensions are 550 x 400 px  The Flash coordinate system  How to write a function to.

Slides:



Advertisements
Similar presentations
Sprite-visual object (actor on the stage) Scripts- Tells actors (sprites) what to do.
Advertisements

Create a Simple Game in Scratch
In this tutorial, we are going to create: A race car that the user can control with the arrow keys for direction and speed. A simulated road with a striped.
Create a Simple Game in Scratch
Lets Play Catch! Keeping Score in Alice By Francine Wolfe Duke University Professor Susan Rodger May 2010.
Warm Up Draw an example of a reflection: Draw an example of a figure that has one or more lines of symmetry: Find the new coordinates of the image after.
Transformations Math 8.
1 Flash Actionscript Animation. 2 Introduction to Sprites We will now look at implementing Sprites in Flash. We should know enough after this to create.
1 Flash Actionscript Adding Interactive Actions. 2 ActionScript 3.0 ActionScript is the language you use to add interactivity to Flash applications, whether.
© 2011 Delmar, Cengage Learning Chapter 8 Building Complex Animations.
GAME:IT Junior Bouncing Ball Objectives: Create Sprites Create Sounds Create Objects Create Room Program simple game.
Guide to Programming with Python
A Scratch tutorial. Description: You have 6 bullets to shoot at 2 targets. Every time you hit any of them you get two extra bullets but the targets get.
TRANSFORMATIONS BY: JESSICA RODRIGUEZ. TEKS FOR 8 TH GRADE TRANSFORMATIONS Two-dimensional shapes. The student applies mathematical process standards.
Game Design Creating a game called PING Phase 3: Steps for building basic game.
MrsBillinghurst. net A2 Computing A2 Computing Projects Game Animation in Pascal.
ITP 104.  While you can do things like this:  Better to use styles instead:
Aim: How can we create a car, bike or truck with rotating wheels using ACTION SCRIPTING?
Introduction to TouchDevelop
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 3 "The games of a people reveal.
Learning Game Maker Studio:
KeyListener and Keyboard Events Just as we can implement listeners to handle mouse events, we can do the same for keyboard events (keypresses) –to implement.
Transformations Translation “Slide” Left: subtract from x-coordinate Right: add to x-coordinate Down: subtract from y-coordinate Up: add to y-coordinate.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 3 "The games of a.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 2 "The games of a.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script "The games of a people reveal.
Game Maker Terminology
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 9 "The games of a.
Review Inheritance Overloading and overriding. example1.pde.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 9 "The games of a people reveal.
Game Maker Galactic Mail Advanced Group: Complete Galactic Mail, then start developing an independent project.
Transformations of Geometric Figures Dr. Shildneck Fall, 2015.
© 2011 Delmar, Cengage Learning Chapter 10 Using ActionScript to Enhance User Experience.
Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008.
Computer Game Design ActionScript is… Object-oriented programming Everything you do in ActionScript does something to some object* Some objects.
Properties or Rules of Transformations Equations used to find new locations.
SCRIPT PROGRAMMING WITH FLASH Introductory Level 1.
Variables and Random Numbers Computer App Session 4.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Action Script 12 "The games of a people.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 12 "The games of.
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
Scratch for Interactivity Dr. Ben Schafer Department of Computer Science University of Northern Iowa.
How to create a basic game in Scratch. The Scratch Stage The Scratch stage is 480 pixels wide and 360 pixels high x increasesx decreases.
Perform Congruence Transformations. Transformations: when you move or change a geometric figure in some way to produce a new figure. Image is what the.
Sprite sets. project of the week: bubble popper o objects appear from the bottom and slide up o player needs to avoid objects to earn points (objects.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script "The games of a people.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 11 "The games of a people reveal.
Creating your own Handheld Games Console
6.03. Do Now – Translate! The position of a box of cookies on a table is represented by the points (-2, 4) (-3, -1) (0, -2) and (1, 3). If the box is.
 Movieclip symbols are reusable pieces of flash animation  consisting usually of one or more graphic/button symbols  thus they are flash movies within.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
Index Background Costumes Making object walk smoothly Controlling an object with the keyboard Control an object with the mouse Changing costume when hit.
Create a Halloween Computer Game in Scratch
Scratch for Interactivity
The Box Model in CSS Web Design – Sec 4-8
Tutorial 3 Creating Animations.
Control Structures
Using Buttons to Create a Simple Site Example: The Color Picker www
Memory Matching Challenge
Introduction to TouchDevelop
ICT Gaming Lesson 3.
Flappy bird Demo: Lesson 5 Flappy bird Demo:
Building a Game in Scratch
Game Over Module 4 Lesson 2.
Creating a Simple Game in Scratch
CSC 221: Introduction to Programming Fall 2018
Animation Translation.
Presentation transcript:

Moving Objects

Objectives You will know …  the Stage default dimensions are 550 x 400 px  The Flash coordinate system  How to write a function to move objects  Left, right, up, down, and diagonally  How to screen wrap a moving object so it repeats its movement  How to set objects at random locations  Initially  When screen wrapping  How to run your function using an add event listener  How to turn off your function a remove event listener

Flash Coordinate System.x is used to move objects from side to side.y is used to move objects up or down

Flash Coordinate System Stage is 5550 px wide and 400 px high (default) An object moving right has an increasing x coordinate The Stage’s x-axis goes from 0 to 550

Flash Coordinate System Stage is 5550 px wide and 400 px high (default) An object moving left has an decreasing x coordinate The Stage’s x-axis goes from 0 to 550

Flash Coordinate System Stage is 5550 px wide and 400 px high (default) An object moving down has an increasing y coordinate y-axis goes from 0 to 400

Flash Coordinate System Stage is 5550 px wide and 400 px high (default) An object moving up has an decreasing y coordinate y-axis goes from 0 to 400

Flash Coordinate System Stage is 5550 px wide and 400 px high (default) An object moving diagonally has a change to both the x and the y coordinates (increasing and/or decreasing)

 This function moves three objects down the Stage Write a Function function moveRocks (e:Event) { rock1.y = rock1.y + 20; //falling rocks rock2.y = rock2.y + 25; rock3.y = rock3.y + 15; } Made up name Varying speeds 3 rocks Notice it is Event, not MouseEvent

 Use a combination operator to write shorter statements cloud.x += 10;  This makes an object with instance name ‘cloud’ move right 10 pixels at a time  The longer way to write the same instruction is cloud.x = cloud.x + 10; Combination Operators

Updating Any Movie Clip Property Continuously (Examples) Rotate Clockwise hand.rotation += 10; Rotate Counter-Clockwise wheel.rotation -= 10; Increase in Size shape.width +=10; shape.height += 10; Move to the Right car.x += 5; Move to the Left car.x -= 5; Decrease in Size star.width -= 10; star.height -= 10; Move Up bullet.y -= 7; Move Down bullet.y += 7; Increase Proportionately shape.scaleX +=.05; shape.scaleY +=.05; Fade Out ghost.alpha -=.05; Fade In ghost.alpha +=.05; Decrease Proportionately star.scaleX -=.05; star.scaleY -=.05;

 Often we want to repeat our movements when an object leaves the Stage so we will add if statements to screen wrap Screen Wrap function moveCloud(e:Event) { cloud.x = cloud.x - 10; //moves left if(cloud.x < 0) { cloud.x = 560; //re-set stage right }

 When your game starts, usually we want our moving objects to begin at random locations  Add code to the main Script pane (not in a function) to set a random start position for each object Random Locations cloud.y = Math.random() * 400; Multiply by 400 so the cloud can randomly be placed on the y-axis anywhere from 0 up to 400

 As the moving object is screen wrapped, reset it to a new random location Random Locations function moveCloud(e:Event) { cloud.x = cloud.x - 10; //moves left if(cloud.x < 0) { cloud.y = Math.random() * 400; cloud.x = 560; //re-set stage right } random y location

 To run your function you can add an event listener which calls each function  You will use the ENTER_FRAME event to make a continuous change Add Your Event Listeners addEventListener(Event.ENTER_FRAME, moveRocks);

 Before you leave a page (to win or lose, for example) you MUST remove all event Listeners that have an ENTER_FRAME event type  Example: You win the game if your score reaches 20 Remove Your Event Listeners! if score == 20) { removeEventListener(Event.ENTER_FRAME, moveStuff); gotoAndStop(3); //win page }