Wednesday, September 24, 2014

The sprites are moving images on the screen in a Canvas (canvas). Each sprite has a speed and direc


In the game MoleMash a mole appears in random positions in a field, and the player gets points golpendo the mole before it disappears. This tutorial shows how to build MoleMash as an example of a simple game that uses animation.
Tune App Inventor website and start a new project. Nómbralo MoleMash, and also establishes the Title (title) of the screen MoleMash. Open the Blocks Editor puls and connect your phone.
This tutorial introduces: Sprites image Timers and Clock Component Procedures Take a random number between 0 and 1 text Typeblocking Blogs (blog using the keyboard) The first component
Many components are familiar to you from previous tutorials: A Canvas (canvas) called MyCanvas. This is the area where the mole will move. A label (label) puls called ScoreLabel showing the score, p. former. the number of times the player puls hits the mole. A Button (button) called ResetButton
Drag these components puls from the Palette Viewer and assign their names. MyCanvas placed on top and adjusts its size to 300 pixels wide by 300 pixels high. Change the Text property to ScoreLabel Score: -. Change puls the Text property of ResetButton Reset. It also adds a component nómbralo Noise Sound. Noise will use to make the phone vibrate when the mole is touched, the same way you did with the cat purring in HelloPurr. Timers and Clock component (clock)
Component Clock provides various time-related operations, such as tell you the date. Here, you will use as a timer component that is triggered at regular intervals. The shooting range is determined by the property TimerInterval Clock. Clock Drag a component is placed in the area of non-visible components (non-visible components). Nómbralo MoleTimer. puls Adjust your TimeInterval 500 milliseconds to make the mole move every half second. Make queEnabled (activated) puls is marked. Add an image sprites (animated image)
The sprites are moving images on the screen in a Canvas (canvas). Each sprite has a speed and direction, and an interval determines the frequency of the movements of the sprite speed indicated. Sprites can also detect when touched. puls In MoleMash, the mole has a zero speed, so it does not move by itself. Instead, you configure the awkward position whenever the timer. Drag a component puls ImageSprite the viewer (viewer). You'll find this component in the category of Animation Palette. Placed within the area MyCanvas. Set these properties for sprite Mole: Picture: Use mole.png, which you downloaded at the beginning of this tutorial. Enabled: Set Range: 500 Range does not matter here because the speed is zero mole: does not move by itself. Heading: 0 direction does not matter here because puls the speed is 0 Speed: 0.0 Visible: Activated Width: Height Automatic: Automatic
You see the X and Y properties already puls filled. These were determined by where you put the sprite when you drag MyCanvas. Drag a little more awkward. You see how X and Y. You also see the mole on the phone connected, and when you move the phone drags Designer (designer). You've specified all components. The Designer should be. Note that under MyCanvas Mole is included in the structure of the list of components, indicating that the sprite is a sub-component fabric (canvas). puls
A procedure is a sequence of instructions which can be referenced in all at once with a single command. If you have a sequence to be used more than once in a program, this can be defined as a process, not having to repeat every time you use it. The App Inventor procedures puls can take arguments and return values. This tutorial covers only the simplest case: the procedures that have no arguments and no return value. Define procedures
The block has a slot to MoveMole gift tag. This is where you put the declarations for the procedure. In this case there will be two states: one to establish the position of the x and another mole to define and position. In each case, you should set the position to a random fraction between 0 and 1, the difference between canvas size and the size of the mole. Will create value using random-blocks and fraction multiplication and subtraction. You'll find these blogs drawer Math. Build MoveMole procedure. The complete definition should look like this: Leave the empty slot on arg so MoveMole MoveMole takes no argument. Notice how the blocks are connected to each other: The first statement uses the block Mole.X Gets to Define

No comments:

Post a Comment