2014년 12월 12일 금요일

List of Ball Sprites - when ball sprite touched, how do I determine which one

Students are creating a quiz app for states.
They have broken the country into 3 regions - put a ball sprite on each state and put the ball sprites into a list.   

On Canvas Touched
On sprite touched
Determine if ball sprite touched = ballsprite for Maine .... etc.


Notes: 
Ball sprites  are in a list - 
Questions are in a separate list (i.e. Where is maine)
Index for Where is Maine question = Index for ballSprite for Maine.

Would like a basic answer that I can use to prompt them through.

Thanks




Here is some basic advice in no particular order - I am assuming high school or higher?    and a group project?:

1) There is a lot going on in this.  Most experienced developers would get one part of the quiz working at a time.  Once one part is working, move on to the next.  That is not happening here if this is a work in progress.  This is a complicated project.

2) The student's screens look nice.  Keep at it.  Do they need to make there own or are these provided.  Using a background image like this on a Canvas is certainly an advanced technique.

3)  When the region screens are left for the main screen, they are not closed.   I do not see a single screen closed block.  Why is this important?  When a screen is opened, it utilizes System memory.  System memory is the Android device's brain.  When another screen is opened, more memory is used.  The problem is the System memory still contains the information from the previous un-closed screen.  Switch several times, and the System memory on some devices will be gobbled up.  Uh oh, gobbled up means the device becomes stupid and the app crashes.   Search for the TribbleHunter method or Taifun's screen manager to learn how to properly exit screens.

4) Do the student's know how to debug?   That is, can they use the built-in debugger called DoIt?

5)  If I were developing this I would not make any calls to the sound blocks until near the end of the project.  Why?  App Inventor 2 is an event driven compiler...it means that one activity has to finish before the next is allowed to proceed.  The sounds are nice and probably will work ok, however programming for them now merely makes the code more difficult to work with.

6)  You realize you have to pass information between screens.  There are two ways to do that, the student's are already using one method.   If they need to pass multiple pieces of information they may need to either pass the information as a List  or to use a TinyDB.

7) Only one of the screens is fleshed out.  This is great.  Get that screen working, copy similar code to the other two screens and you are golden.

8) It would help the student's to READ the chapters 14 to 24   in AI2 free online eBook   http://appinventor.mit.edu/explore/ai2/tutorials.html   ... the links are at the bottom of the Web page   and Lists by Lists Sajal    http://www.imagnity.com/tutorials/app-inventor/list-blocks-on-app-inventor/

9) They should also read:  Language:  http://appinventor.mit.edu/explore/ai2/support/blocks.html


Though these documents are the technical stuff (no pictures), but they explain to those who understand programming, how the controls and block language is supposed to work.


Some of the other people here will have different ideas.  I am not sure I answered your question because I am not sure what your question is.   Is this doable...certainly. Some people will want to see screen capture images of your blocks and "won't bother to look at the aia."



Steve has really good advice to you here, but I think one of your questions was: how to figure out which ball was touched. Unfortunately this is not such an easy question to answer, because if you use thewhen Canvas1.Touched event block, the touchedSprite argument is a boolean. It tells you that a a sprite (or a ball) was touched, but not which one. Maybe you could do some calculations by using the x and y postions, but that is cumbersome. Therefore, the best thing to do is using a when BallWhatever.Touched block for every ball. Each of these blocks can be very simple, leaving the processing to a procedure. I attach a picture of how this could work:


댓글 없음:

댓글 쓰기