Académique Documents
Professionnel Documents
Culture Documents
http://kio4.com/appinventor/index.htm#indice
- Qu es Android?
Android es un sistema operativo gratuito que utiliza muchos telfonos
mviles actuales (telfonos inteligentes = smartphone), est basado
en LINUX. Android pertenece a Google.
- Cmo es el cdigo?
- En forma de Bloques...
Los programas se realizan mediante bloques, que son una especie de
piezas de puzzle.
No tiene programa fuente escrito en texto.
http://appinventor.googlelabs.com
_____________________
____
- En qu direccin entro para
programar?
http://ai2.appinventor.
mit.edu
App inventor 2 en
espaol
http://beta.appinventor.mit.edu (versin antigua)
_____________________
____
Interface
- Podemos trabajar en espaol, en ingls, francs, italiano...
App inventor 2 en espaol offline
- Hemos visto que para trabajar con
AI2 debemos estar conectados a
Internet, se podra trabajar de
alguna manera offline, es decir sin
estar conectado?
- Pus s, para ello un equipo distinto al MIT ha creado un AI2
Ultimate con Personal Server. Esto instala el AI2 en nuestro
ordenador, utilizando JAVA. Luego en un navegador
escribimos http://localhost:8888 y podemos trabajar directamente
con nuestro ordenador sin estar conectado a Internet.
La versin ai2u 2.3 ya viene en espaol.
Bajar de aqu.
Arrancamos el Server, vamos a un navegador y
escribimos http://localhost:8888
Ayuda.
__________________________________________
__________________
__________________________________________
__________________
__________________________________________
__________________
__________________________________________
__________________
__________________________________________
__________________
EMPEZAMOS AQU...
_________________
1.- Nuestro primer proyecto.
Teorema de Pitgoras.
p1_pitagora Baja este archivo a tu ordenador y
luego sbelo a App inventor
s.aia (Proyectos / Importar proyecto)
Nota: cateto viene del latn cathetus, y este del griego ???et??,
significa: perpendicular.
- Pulsamos Proyectos / Comenzar un proyecto nuevo...
Le ponemos como nombre: pitagoras
_________________
Diseador
Screen1 es la pantalla de nuestro mvil.
Un Botn (Botn1)
Diseador y Bloques.
Para Disear nuestros controles pulsamos Diseador.
Para poner los Bloques del cdigo pulsamos Bloques.
_________________
Bloques
Pulsamos en Bloques para poner los Boques de cdigos...
En la parte izquierda tenemos los Bloques para
poner cdigos y los controles que hemos puesto en
la pantalla Screen1.
Dentro de Botn1.Click
- Tomamos el contenido del CampoDeTexto1.Text y lo asignamos a
la variable x
- Tomamos el contenido del CampoDeTexto2.Text y lo asignamos a
la variable y
El programa pasar a tu
mvil.
- El programa quedar
conectado hasta que
los desconectemos
(Conectar / Reinciar
Conexin)
- Si cambiamos algo en
el Designer o en los
Bloques inmediatamen
te pasar al
programa del mvil.
- De esta manera
podemos depurar
(debug) los programas
que realicemos hasta
que funcionen
correctamente.
_______________________________________
SEGUNDA FORMA:
2.- Instalamos un EMULADOR en nuestro ordenador con
Windows (este emulador tambin vale para LINUX aunque es ms
difcil de instalar), de esta manera podemos hacer las pruebas de
funcionamiento en el emulador del ordenador y cuando funcione
correctamente lo pasaremos al mvil.
En este caso no nos hace falta mvil ni Wifi para probar nuestra
aplicacin.
(http://explore.appinventor.mit.edu/ai2/setup-emulator )
- Instalamos en nuestro ordenador con Windows el App Inventor
y aiStarter.
http://explore.appinventor.mit.edu/ai2/windows (100 MB)
(Tambin se puede instalar este programa en LINUX, pero es algo
ms complicado)
___________________________________
TERCERA FORMA:
3.- En caso que no tengas WiFi, conectaremos nuestro programa
desde el ordenador al mvil mediante cable
USB. (http://appinventor.mit.edu/explore/ai2/setup-device-usb.html)
- El programa quedar
conectado hasta que los
desconectemos (Connect
/ Reset Connection)
- Si cambiamos algo en el
Designer o en los
Bloques inmediatamente
pasar al programa del
mvil.
- De esta manera
podemos depurar
(debug) los programas
que realicemos hasta que
funcionen correctamente.
___________________________________
___________________________________
___________________________________
___________________________________
p1_pitagoras.apk
Lo puedes instalar en tu mvil escaneando este cdigo QR:
Cmo he creado este cdigo QR?
He pulsado en App (guarda archivo .apk en mi ordenador)
http://kio4.com/appinventor/aplicaciones/p1_pitagoras.apk
___________________________________
Guardar el programa
- Como acabamos de ver, podemos crear nuestro programa y
obtendremos un archivo de la forma pitagoras.apk que podemos
guardar en nuestro ordenador y instalar en el mvil para su
funcionamiento.
El archivo pitagoras.apk se denomina programa compilado, es decir
preparado para instalarse y funcionar.
___________________________________
__
___________________________________
__
___________________________________
__
___________________________________
__
2.- MEJORAS.
- Colores, Centrado, Imagen
p1_pitagoras2 (varias pantallas - Screen)
Vamos a continuar con nuestro proyecto de pitagoras mejorndolo.
Primero vamos a guardar nuestro proyecto con otro nombre para tener
una copia de seguridad, para ello vamos a Mis Proyectos / Guardar
proyecto como...
y le ponemos de nombre pitagoras2
Medios / SelectorDeImagen
en su Propiedad
Imagen ponemos la imagen
de pitagoras.gif que acabamos
de subir.
DisposicinHortizontal.
Ponemos DisposicinHorizontal
que ocupe todo el Ancho de su
contenedor.
Lo centramos.
Podemos centrar los controles
horizontalmente, verticalmente o
en tabla, de tal manera que
podemos poner varios controles
en cada una de esa disposicin.
__________________________________________
_
Agregamos un VisorDeLista1.
Podemos agregar elementos al VisorDeLista1 mediante la
Propiedad ElementosDesdeCadena, separando los nombre de los
elementos mediante coma.
Ponemos: Uno,Dos,Tres
Vamos a Bloques
Para ello utilizo dos tablas, en una figura el nombre de dos elementos
del VisorDeLista1 (Pitgoras, rea del tringulo)
en otra tabla establezco el nombre de dos pantallas (Screen1 y
Screen2).
Para que una vez en una de las pantallas podamos volver el men,
vamos a crear en la Screen1 y Screen2 sendos botones
Botn2_Click, de manera que cuando los pulsemos se vuelva a la
pantalla Screen3.
__________________________________________
_
- Backpack.
_______________________________
____
_______________________________
_______________
Resumen de instalacin.
- Podemos trabajar online y offline.
_________________________________
_______________________________
Configuracin del Router
- Si tenemos un Router domstico en nuestro hogar, no es
necesario configurarle nada.
Observa
que para
que este
Router est
en la misma
red, se
debe
conectar a
uno de sus
puertos
locales LAN
(color
amarillo en
la imagen),
NO al
conector de
Modem
WAN (color
azul en la
imagen).
Adems
debemos
entrar en la
configuraci
n del
Router,
ponerle una
contrasea
y DESHABI
LITAR su
DHCP.
_________
_______
Si
dispones
de Andared
, puedes
configurar
que tanto
el porttil
como el
mvil
funcionen
en esta
red.
_______________________________
___
Proyecto Integrado
(Introduccin a la
Programacin de Mviles)
Entrega Prctica 7:Galeria de
imgenes
La prctica consiste en hacer una aplicacin donde el usuario tiene una galera
de imgenes. Cuando pulses en la imagen aparecer una pantalla con la
imagen d
This tutorial shows you how to build a game similar to the Whac-A-MoleTM arcade game. Specifically,
your goal is to tap a mole that randomly pops out of one of five fixed holes. Every time you succeed,
your score is increased by one point.
In order to highlight new App Inventor features the Advanced tab and Sprite Z-layering this app
takes a different approach than the original Mole Mash tutorial, which you do not need to have
completed in order to do this one. You should, however, be familiar with the basics of App Inventor
using the Component Designer to build a user interface and using the Blocks Editor to specify event
handlers. If you are not familiar with the basics, try stepping through some of the basic tutorials before
continuing.
Introduction
Connect to the App Inventor web site and start a new project. Set the screen's Title property to an
appropriate name, such as "Mole Mash". Open the Blocks Editor and connect it to the phone. Download
these image files (created by Yun Miao) by right-clicking on them, then add them to the project by
pressing the "Add..." button in the Media pane.
Set up the Components
The user interface will contain a total of 6 ImageSprites: 5 unmoving holes and 1 mole, which will move
on top of the holes. Use the component designer to create the user interface. When you are done, it
should look something like the picture below. Don't worry about lining up the holes evenly. You will
specify their locations through their X and Y properties. Additional instructions are below the picture.
Create the following components by dragging them from the Palette into the Viewer.
ImageSprite (5) Drawing and Animation Hole1 ... Hole5 Holes from which t
Component Action
Canvas1 Set BackgroundColor to Green. Set Width to 320 pixels. Set Height to 320 pixels.
Mole Set Picture to "mole.png". Set Z to 2 so the mole appears in front of the other ImageSprite s, which h
c. Call MoveMole .
To proceed, switch to the Blocks Editor.
Creating Variables
Create the variable holes. For now, we will give it a "dummy" initial value of an empty list; we'll set the
real initial value in the Screen1.Initialize event handler, which gets executed each time the app loads the
screen. (For technical reasons, components cannot be referred to in variable initialize blocks, which are
run before the app has started.) Here is a picture and list of the blocks you will need:
Block type Drawer Purpose
create empty list Lists Create an empty list, to be filled in when the program sta
As always, comments (created by right-clicking on a block) are encouraged but not required.
The first event to occur in any program in Screen1.Initialize , so we will put start-up code in that handler.
Specifically, we will add the hole components to the list holes, set each hole's Picture property to
"hole.png", and call MoveMole . Since we have not yet written MoveMole, we will create an empty
procedure with that name, which we will fill in later.
Below are a picture and table of the blocks you need to create. Note that the "Any ImageSprite" drawer
is found under the "Any component" tab at the bottom of the list of Blocks in the Blocks Editor.
for each hole in list Control Specify that we would like a variable na
get global holes Variables ...to take on each of the values in the li
set ImageSprite.Picture of component ... to Any ImageSprite Set the Picture property of...
" " (hole.png) Text ...to the picture of the empty hole.
Compare the for each block to the equivalent blocks that would be necessary without it:
Not only is the left set of blocks shorter, it is less repetitious, sparing the programmer from semi-
mindless copy-and-pasting and making it easier to modify, for example, if the name of the picture is
changed.
Now let's fill in the body of the procedure MoveMole, which we'll call when the program starts, when
the mole gets touched, and when our timer goes off every second. What we want it to do is to pick a
random hole and move the mole on top of it. Here are a picture and list of the new blocks:
Block type Drawer
Registering Touches
Finally, we need to specify what happens when the mole is touched. Specifically, we want to:
1. Increment the score.
2. Make the phone vibrate briefly.
3. Move the mole.
We can easily translate these to blocks:
Final Program
Variations
Scan the following barcode onto your phone to install and run the sample app.
Or download the apk
Download Source Code
If you'd like to work with this sample in App Inventor, download the source code to your computer, then
open App Inventor, click Projects, choose Import project (.aia) from my computer..., and select the
source code you just downloaded.
Tutorial Version:
App Inventor 2
Tutorial Difficulty:
Intermediate
Tutorial Type:
Sprites
Clock Timer
Game
inShare
Home
About
About Us
Our Team
Sponsors
News & Stories
In The News
Stories
Team Blog
App of the Month
Resources
Get Started
Teach
Documentation
Tutorials
AI Classic
Resources
Forums
Troubleshooting
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License
2012-2015 Massachusetts Institute of Technology
Contact Us