Upgrade to Pro — share decks privately, control downloads, hide ads and more …

2_2_8-Ball(魔术8球)

powerhope
August 11, 2016
120

 2_2_8-Ball(魔术8球)

App Inventor移动应用开发

powerhope

August 11, 2016
Tweet

Transcript

  1. College of Mathematics and Computer Science, Hunan Normal University 

    服务器网址 ◦ http://ai2.appinventor.mit.edu/ ◦ http://app.gzjkw.net  资源 ◦ http://appinventor.mit.edu/ 网址
  2. College of Mathematics and Computer Science, Hunan Normal University 

    当完成这个App,摇晃一下手机,你会收到 一个预言。 8-Ball(魔术8球)
  3. College of Mathematics and Computer Science, Hunan Normal University 

    用Chrome (谷歌浏览器) 打开了App Inventor 主 页http://ai2.appinventor.mit.edu或 http://app.gzjkw.net  用你的电子邮件地址账号注册和登录.  如果已经创建了项目(如HelloPurr),系统将自 动进入到上次项目的设计界面,点击左上角的“项 目” 登录服务器
  4. College of Mathematics and Computer Science, Hunan Normal University 

    如果点击“我的项目”将进入到项目列表;直接点 击“新建项目”按钮。 新建项目
  5. College of Mathematics and Computer Science, Hunan Normal University 

    Magic8Ball应用中需要四个可视组件:  一个“按钮【Button】”组件,显示8球;  二个“标签【Label】”组件,显示文字“问魔术8 球一个问题”和“点击魔术8球来收到一个回答”;  一个“垂直布局【VerticalArrangement】”组件 ,用来布局标签组件。  一个非可视的“声音【Sound】”组件,用来播放 声音。  一个“加速度传感器【AccelerometerSensor】” 组件,用于检测设备的摇动。 界面设计
  6. College of Mathematics and Computer Science, Hunan Normal University 

    上传素材(magic8ball.jpg和Tada.mp3) 界面设计
  7. College of Mathematics and Computer Science, Hunan Normal University 

    增加按钮并修改属性  “图像”属性,选择“magic8ball.jpg”  “文本”属性:删除“按钮1文本”  “宽度”和“高度”分别为“300像素”。 界面设计
  8. College of Mathematics and Computer Science, Hunan Normal University 

    增加界面布局组件。从“组件面板”的“用户界面 ”中拖动“垂直布局”到“Screen1”的按钮下面 实现单击按钮,输出一个预言
  9. College of Mathematics and Computer Science, Hunan Normal University 

    在“组件面板”的“用户界面”中拖动“标签”到 “Screen1”中“垂直布局”里面  用鼠标选定添加的“标签1”,在“组件属性”窗 口中修改“文本”为“问魔术8球一个问题”。用 同样的方式增加“标签2”,文本为:“点击魔术8 球来收到一个回答” 增加标签
  10. College of Mathematics and Computer Science, Hunan Normal University 

    打开块编辑器,即逻辑设计 添加组件行为
  11. College of Mathematics and Computer Science, Hunan Normal University 

    单击块编辑器中“模块”下的“Screen1”中“标 签2”,在弹出的抽屉中选中“设 标签2.文本 为【 set Label2.Text to】”模块并拖放到前面添加的 代码块中。 添加组件行为
  12. College of Mathematics and Computer Science, Hunan Normal University 

    为了实现触摸魔术8球就会得到一个答案,采用“ 列表【Lists】”存放答案,每次从答案中随机选择 一个。列表相当于一个集合可以存放多个答案。 添加组件行为
  13. College of Mathematics and Computer Science, Hunan Normal University 

    假设这里需要设置6个答案:那是肯定的、毫无疑 问、在我看来,是的、别指望它、我的消息来源说没 有、无法预测现在。
  14. College of Mathematics and Computer Science, Hunan Normal University 

    添加“加速度传感器”,并添加代码块 实现晃动手机,输出一个预言
  15. College of Mathematics and Computer Science, Hunan Normal University 

    如果你想把应用分享给朋友或发布到应用市场,就 需要把应用打包成apk文件。AI2提供了二种打包方 式。  打包apk并显示二维码  打包apk并下载到电脑 打包和下载应用
  16. College of Mathematics and Computer Science, Hunan Normal University 

    丰富Magic8Ball内容,让它变得更有趣。 实验三