2017년 3월 24일 금요일

Start then Pause


Can you please solve this problem.
When I click start; pause; start and pause continually, the pause button doesn't work when I click it one more time, although it works in the first click.

1.png 표시 중




-- 
I just tried your test app and switching between Start and Pause continually works fine for me on Nexus 5X running Android 7.1.1 using the companion app
what device/Android version are you using?



 the pause button doesn't work
what does that exactly mean? the sound does not pause, but continues playing?
what happens, if you use the built in Player component instead of the Player extension?

-- 
Actually, I use Galaxy J7 and HTC. When Push Play Button then pause Button then play Button, I cannot pause again, It plays unless I stop the playing. I need to use Taifun extension for making blocks of current position and and start position.

-- 
did you try the Player test app? do you get the same issue there?
-- 
Yes I tried it. it is the same problem.

-- 
unfortunately I'm not able to reproduce that issue...
I will add a note onto my webpage
you might wnt to provide the exact device name and Android versions you are using...

-- 
see this workaround provided by Hussein:

Note: I received the following feedback from Hussein: I found when Play then pause then play, I cannot pause again. It will be stuck on play unless I stop the playing. The workaround is when clicking pause the program should read the current playing position before pausing, then stop instead of pause, and when want to play, use the play at that position. Thank you Hussein!

-- 
Can you please explain what can I do?
Is there any mistake in building the blocks. Please explain to me in more details.


--
use the workaround from Hussein

The workaround is when clicking pause the program should read the current playing position before pausing, then stop instead of pause, and when want to play, use the play at that position


 -- 
Now I have got it.
I really appreciate for your great help.


--
the Pause bug in the Audio Player extension should now be fixed

-- 

How to make the program wait for either a yes or no response from a Notifier


Can I use a notifier to display a message and make the program pause until the notifier is acknowledged?
As it is the program continues running with the notifier on screen 

--
I'm hardy experienced, so there probably is a way, but in case there isn't you could set a global variable.  If the global variable is false, don't run code.

-- 
I ran a test of the Notifier Choice block, with a Clock and a bouncing ball.
Neither stopped.

So you have to keep track of all your moving parts and stop them yourself.

See attached for The World's Dumbest Number Guesser app.


Capture.PNG 표시 중


--
App Inventor will never wait...

use the Notifier.ShowChooseDialog and continue your logic in the AfterChoosing event

--
If App Inventor will never wait what is the point of having When Notifier1. AfterChoosing if it never waits for an answer

-- 

IApp Inventor will never wait what is the point of having When Notifier1. AfterChoosing if it never waits for an answer
It's all about having an answer to the choice question, not about waiting.


So if the question is "Should I Quit?"  the Quit block would
be in the AfterChoosing event block, guarded by a test for "Yes" reponse.

You weren't considering putting the Quit block after the block where you ask the question,
were you?

-- 
No, The programs asks 30 questions, after every question is read out by the program it checks the answer given and if correct the score is increased by one, when the score hits multiples of 10 i want a popup notifier to appear and the program to wait for the acknowledge button press from the notifier before asking the next question.

-- 
It's time for you to post some blocks.
Provide both a downloaded blocks image amd an exported .aia

-- 


-- 
(going offline for a day.  Throwing this thread up for any one available)

-- 
How about running the code to ask the next question in the notif's AfterPicking or whatever handler?

-- 
Like move the code in NewWord.Click to a function, then call that function in the AfterPicking handler as well.

-- 
the newword button is there to skip that question and move onto the next question so I have it set in the submit button function where it checks the answer

-- 
Okay.  First, why do you want two buttons, one with "O" and the other with the k?  Is there any specific reason?  I suggest using the block in screenshot two, which only displays one button.

Screen shot 2017-03-17 at 6.22.05 PM.png 표시 중

Screen shot 2017-03-17 at 6.22.14 PM.png 표시 중

-- 
I know this isn't addressing the issue you posted about, but in the notifier's afterChoosing handler you set the background image to a media file that isn't uploaded.  I think you forgot that there file.  ;)

Screen shot 2017-03-17 at 6.25.09 PM.png 표시 중

-- 
no particular reason, id actually prefer just one button but I could not get the one you posted to work either

-- 
I haven't fully looked over all the code, but since you're the author and probably know it backward and forward, how about calling the GetWord function from the Notifier's AfterPicking handler?  Do you think that would work?

P.S. I notice the set bronze, set silver, and set gold blocks have warnings.  I don't see them added to this screen.  Did you accidentally delete those components?

Screen shot 2017-03-17 at 6.27.59 PM.png 표시 중

Screen shot 2017-03-17 at 6.29.07 PM.png 표시 중

Screen shot 2017-03-17 at 6.29.10 PM.png 표시 중

Screen shot 2017-03-17 at 6.29.12 PM.png 표시 중

-- 
As for the notifier thing, perhaps the blocks I've attached would do the trick?

Screen shot 2017-03-17 at 6.30.55 PM.png 표시 중

Screen shot 2017-03-17 at 6.31.14 PM.png 표시 중

-- 
Works for me.  :D

When the screen initializes, the current word is not spoken.  Perhaps you can add a notifier:
Click the Okay button (the button in the notifier) when you're ready to begin.

And then you can call GetWord.

On a different subject, how about making a global variable and setting it to the listFromCsvRow[list in text here]?  Then you can use the list length block in your if statement in the GetWord function.

Screen shot 2017-03-17 at 6.34.27 PM.png 표시 중

-- 
the bronze silver and gold things are additional bits that are in the full app code and that part works without problem, what i posted is a cut down of my main program just to show the part I am having issues with.
And as for calling the getword function from the Notifier's AfterPicking handler that will not work as the notifier is only called when 10 answers have been input correct while the getword function is called to choose a new question

-- 
I thought that was what you wanted, to have the game go to the next word after the notifier is Okayed.  Sorry, I misunderstood you, I'm thinking.

-- 
I think the next step would be to explain, specifically, what you want to happen.

-- 
P.S.  Another question: Why do you have two TextToSpeech components?  Why do you need two?  Does one have a different setting or something?

-- 
the app asks questions and every 10 correct answers the notifier pops up, and the app should not ask the next question until the notifier is dismissed but for whatever reason the app still asks the next question while the notifier is active

-- 
use the Notifier.ShowChooseDialog and continue your logic in the AfterChoosing event
same for silver and gold

-- 
This may be just a bandage, but time the amount of time the notifier shows, and set and use clock component to wait until after the notifier's gone.

-- 
Nothing is being chosen, @Taifun.

-- 
Specifically, in submit.Click see if you're on a multiple of 10.  If so, switch the clock on and show the notif.  In the clock's handler for when the time ends, then go to the next question.

-- 
app
this is because you do not continue with the logic in the AfterChoosing event
you might want to take a look at the corrected screenshot here https://groups.google.com/d/msg/mitappinventortest/ROyJZEmXUgY/oeq8EzVgGgAJ

-- 
wont work because the notifier is only ever called when 10 CORRECT answers have been given not every questions

-- 
Well then try what I suggested when you're on a multiple of 10 correct.

Yes, sleeping on it may give you a fresh view tomorrow.  Good St. patrick's Day luck to you!

--
what about this pseudo code?

if 10th correct answer 
then open notiier.ChooseDialog
else continue with your logic

AfterChososing
  continue with your logic

the "continue with your logic" part could be a procedure...

-- 
But he's using alerts where there is no choosing.

--
OK after sleeping on it I have come to the conclusion that the notifier will simply not do what I was hoping it will do as the notifier if called within a loop allows the loop to continue running whilst the notifier is still visible on the screen, I am therefore going to try this from another approach, its a bit more complex for me to do but it might be possible, I will post back if it works or not

-- 

Learn app inventor Make a shopping list APP tutorial


Hello friends, today I have an interesting beginners tutorial for App Inventor and it is not about a game. It is about how to make a shopping list app in app inventor. 
This tutorial covers some interesting points.
The idea is simple , for this shopping list app , we have 3 screens, in one we create the shopping list using textbox and tinyDB then this list "creates" in screen2 a group of CHECKBOXES, these check boxes are the ones we use while buying at the market, then when we check the checkboxes jeje they make 2 lists for a shopping list report and pass this report to Screen3 , the report says which item we buy and wich ones we couldn't get. 
Also I add an extra feauture, I add a simple calculator to help us while buying to know how much are we spending. unfortunately this calculator part is NOT in this tutorial. SO if you want to SEE part 2 please LIKE LIKE LIKE LIKE the video and please SHARE SHARE SHARE it and let me know you are interested in part 02 :( jeje have a nice weekend guys .


Learn app inventor Make a shopping list planner APP tutorial 01



Hello friends, today I have part 02 tutorial for this App Inventor Shopping list planner. So tutorial is about how to make a shopping list planner app in app inventor.
This tutorial covers some interesting points.
The idea is simple , for this shopping list app , we have 3 screens, in one we create the shopping list using textbox and tinyDB then this list "creates" in screen2 a group of CHECKBOXES, these check boxes are the ones we use while buying at the market, then when we check the checkboxes jeje they make 2 lists for a shopping list report and pass this report to Screen3 , the report says which item we buy and wich ones we couldn't get. 

Learn app inventor Make a shopping list planner APP tutorial 02



This tutorials cover some interesting points.
The idea is simple , for this shopping list app , we have 3 screens, in one we create the shopping list using textbox and tinyDB then this list "creates" in screen2 a group of CHECKBOXES, these check boxes are the ones we use while buying at the market, then when we check the checkboxes jeje they make 2 lists for a shopping list report and pass this report to Screen3 , the report says which item we buy and wich ones we couldn't get. 
Also I add an extra feauture, I add a simple calculator to help us while buying to know how much are we spending. 


Shopping List Planner App made in App Inventor. | App Inventor Tutorials | azaotl



WAnt to learn about:
making lists in app Inventor? 
https://goo.gl/hWKp7z
using " for each" loop
https://goo.gl/fS5aGt
Mario Run Game in App Inventor
https://goo.gl/XtKoej

Be my patron: 
http://patreon.com/AzaotlTutorials 
Like my Facebook Page: http://www.facebook.com/azaotl

MIT App Inventor is an innovative beginner's introduction to programming and app creation that transforms the complex language of text-based coding into visual, drag-and-drop building blocks. The simple graphical interface grants even an inexperienced novice the ability to create a basic, fully functional app within an hour or less.
MIT App Inventor has grabbed the attention of:

Formal and informal educators who have used MIT App Inventor to introduce programming to their Computer Science students, science club members, after-school programs’ attendees, and summer campers. Many educators have also started to use MIT App Inventor to develop apps in support of their own instructional objectives.
Government and civic employees and volunteers who have harnessed the power of MIT App Inventor to develop custom, often hyper-local apps in response to natural disasters and community-based needs.
Designers and product managers who have seen the potential that MIT App Inventor has to support the iterative design process via rapid prototyping, testing and iteration.
Researchers who use MIT App Inventor to create custom apps that can process their data collection and analysis requirements in a wide variety of fields from medical to social.
Hobbyists and Entrepreneurswho want to quickly turn an idea into an app without the cost or learning curve of more traditional app creation processes.


Drag and Swap Puzzles in JSON


Abe Getzler
Art and puzzle design by Red Scorpion
2/2017




Motivation

This sample app is a showcase for how to avoid sprite cannibalism in a drag and drop app, plus how to use JSON encoding to load complex data structures simply and flexibly.  The evolution of the app can be seen in this AI2 board thread:  Drag and swap of two canvas error
Original puzzle design and art are by Red Scorpion.

The App


The app runs off different puzzle files, with a Welcome Notifier when a puzzle is loaded.



Back and Next buttons let the user go through a list of puzzles.  


Each puzzle consists of an arrangement of 9 colored square sprites, that have to be dragged into the proper arrangement.  





A square being dragged, mid-drag.  When it is dropped, it will change places with the square it was dropped onto.  Actually, it pops back to where it was before the drag, and swaps picture file names with the target sprite.  The result looks the same.)





A hint button hides the Canvas and its Sprites, then reveals an image of that puzzle’s solution, and a label telling how many sprites have the right image in the right place.


A Close Hint button gets you back to the puzzle.


(Note for further work … the Hint buttons should also hide the Next and Back buttons, otherwise you could switch puzzles mid-hint.)


Designer


This app is all in Screen1, in fixed nonscrollable mode.  The GUI consists of:
  • ImageHint1, a 300 by 300 pixel hint image, normally hidden
  • Canvas1, a 300 by 300 Canvas for the drag and drop puzzles,
    • Sprites P1-P9, 100 by 100 each, on the Canvas in a grid.
  • A Horizontal Arrangement with:
    • btnBack and btnNext to decrement or increment the current puzzle number, and load the new puzzle number
    • lblCorrect, shown during the Hint display, to tell how many sprites are correct.
  • Hint and Close Hint buttons.  The Close Hint button only shows during hint display.

Other Components

  • TinyDB is used to save the current puzzle number, and each puzzle’s last arrangement of sprite images under the tag “PuzzleN/save” where PuzzleN is the puzzle name.
  • Notifier1 is used for the Welcome popup, and can be used for other popups like Congratulations (not implemented.)
  • FilePuzzles is a File component for loading the puzzles.txt file, which holds the names and file names of all the puzzles.
  • FileCurrentPuzzle is a File component to handle loading a puzzle.
  • Web1 is there for JSON conversion support, though no web access happens.

Media Drawer


The Media Drawer has the uploaded puzzle sprite images, hint images, individual JSON puzzle files and a master file puzzles.txt pointing to the list of JSON puzzle files.


Puzzle Storage

puzzles.txt


This file is in Comma Separated Values (CSV) format, with one row per puzzle.
Each row has two columns, a puzzle name and the file name of the JSON file for that puzzle.  The JSON file is read-only, with everything to start a puzzle.

Puzzle1.json


This is an image of the web site www.jsoneditoronline.org where I found a very nice free online JSON editor.  It has Load and Save facilities, and you can change the shape of your data, with no need to install any editor program.


(A Non-programmer’s introduction to JSON:


If you are offline, you can still used a simple program like Windows Notepad or Notepad++ to edit your JSON file, but you will have to be very careful not to break its structure.

The important lesson here is to not change any of the punctuation ({}:,[]) or the tag names (“puzzle”, “name”, “hint”, “start”, “end” ) used by this app to pick out pieces of data from the JSON file, otherwise that part of the app will fail on it.


The file being editted is Puzzle1.JSON, which describes Puzzle1, the first puzzle.
It has 4 parts:
  • name - the puzzle name
  • hint - the name of the hint image file in the Media Drawer
  • start - an array (list) of the starting picture file names for sprites P1 ...P9
  • end - an array (list) of the target picture file names for sprites P1 ...P9 to judge completion (notice how the order is different from the start list, otherwise this would be a very boring puzzle.)
The four tag names mean nothing to JSON or AI2.  They are wired into the blocks for this app, soon to come.


Given the sample files Puzzle1.json and Puzzle2.json, it should be possible to send a non-programmer away to develop more puzzles with an art program and a JSON editor, without changing any AI2 blocks.  That’s a technique used by professional game development companies to save money, that you can use, now that you know JSON.


Processing

Screen1.Initialize


Not much needs to be done at Screen1.Initialize, except launching a File Read of puzzles.txt from the Media Drawer (//) and adjusting the sizes of all the sprites to fit 3 by 3 puzzles.
If this app is extended to include other shapes, like 4 by 4, the puzzle JSON files would need to include rows and columns attributes for each puzzle, and the set_sprite_sizes procedure would need to be called after each puzzle file is loaded, based on that puzzle’s rows and column values.


set_sprite_sizes


This procedure fits all the sprites returned by procedure all_sprites onto Canvas1.


all_sprites

This procedure returns a list of all the sprites in the game.  It is a result procedure instead of a global variable because you can’t define component blocks before the app runs, and this way you don’t need to clutter up Screen1.Initialize with loading up the global variable.


When FilePuzzles.GotText


This event fires after the text from loading puzzles.txt arrives. For debugging purposes, a copy of the text is saved in a global variable puzzles_loader_table_text, then run through a list from csv table block into the global variable puzzles_loader_table.


We check TinyDB tag “CURRENT_PUZZLE_NUMBER” to see if we were in the middle of a puzzle we should resume, otherwise start at puzzle 1, assigning it into global variable current_puzzle_number.


We call procedure begin_load to start the loading process for the current puzzle number.

begin_load


Each time we load a puzzle, that’s a good time to set the CURRENT_PUZZLE_NUMBER tag/value in TinyDB for the next run.  SInce the global puzzles_loader_table has been loaded, we can refer to it by row and column, to set global current_puzzle_name and to start a read from the appropriate JSON puzzle file, named in column 2 of the table.


When File_currentPuzzle.GotText


Following good debugging practice, we pass the incoming text through a global variable to allow us to see it in a Do It in the Blocks Editor.  This is the same text we saw earlier for Puzzle.json before we transform it into a JSON list structure using the Web1.JsonTextDecode block and save it in the global loaded_puzzle variable.


The hint image file name is now available, through the hint function, so we load it into the ImageHint1 component Picture.


We now have access to the start sprite image list for this puzzle, so we can call load_sprite_pictures to change the sprite Picture attributes for all 9 sprites to either the last save or the start values, if this is a new puzzle.


It’s also a good place to pop up a welcome.


hint

This procedure extracts the hint image file name from a puzzle JSON structure.It uses the puzzle function to strip off the outer level to get at the pairs inside it using the list block lookup in pairs. The text block “hint” has to exactly match the tag “hint’ in the JSON file for this to work.
Puzzle
This procedure strips off the outer wrapper from the puzzle JSON tree and returns a list of pairs (attribute, value) with the four parts of a puzzle.  The attribute names are the keys, not the order.


last_save


This procedure is intended to retrieve the last save of this puzzle, from Tinydb, if available.  The save consists of the list of sprite Picture file names in the 9 sprites at the last save operation.
The TinyDB tag consists of a JOIN of the puzzle name (“Puzzle1”) and the extension “/save”.  This lets us keep saves for all the puzzles.


If the TinyDB GetValue comes up empty, we look for the “start” tag in the current JSON puzzle and use that.


load_sprite_pictures


This procedure receives a list of the sprite picture file names to be loaded into sprites P1, P2, … P9.  Procedure all_sprites returns our list of sprite components. We walk the list, index by index, and assign matching positions, using one of the Any Sprite component blocks.


Bug warning … If this is extended to allow puzzles with less that the total number of sprites, say 2 by 2 puzzles, this would fall off the end of the list pictures.  Using length of list(pictures) would probably fix that.

welcome


Not much to say here.


Next and Back Buttons


The Next and Back buttons move the current_puzzle_number global variable forward or back, subject to the total number of puzzles in the global puzzles_loader_table.
The Next and Back buttons are enabled or disabled depending on which limit has been reached.

This is double protection against falling off the end of the puzzles table.

Puzzle mechanics

When P1.Dragged

Each of the 9 sprites has a Dragged event block.  They all call the common procedure handle_drag, passing it that Sprite component, and the currentX and currentY of the drag event.


handle_drag


This procedure contains code to avoid sprite cannibalism, where extra sprites try to follow your finger as you drag another sprite near them.  The two tests handle that - a global true/false value dragging to indicate that we are in the middle of a drag operation, and a global variable dragged_sprite to hold the component that we decided to drag when we started a drag operation.
If this sprite is the currently dragged sprite, then we move it, with some adjustments so it doesn’t get obscured by our finger as it’s dragged.


If a drag operation starts while the dragging variable is false, then we handle it like it was a touchDown event, and call procedure handle_touchDown.

handle_touchDown


This procedure is called at the start of a drag sequence.  We announce in the global dragging variable that a drag has started, and save the current sprite parameter in the global dragged_sprite.  We also save the X and Y values of this sprite in the two globals dragged_start_X and dragged_start_Y, for the snapBack operation when we let go of the drag.
To show the dragged sprite better, we raise its Z value.


When P1.TouchUp


The drag operation ends when we release the dragged sprite, signalling a TouchUp event for that sprite.  We pass the component to procedure handle_touchUp.


handle_TouchUp


This procedure also protects against sprite cannibalism in the surrounding IF/THEN test, to insure it will happen only for the currently dragged sprite, and only during a drag operation.
If the two tests are satisfied, it sets the global dragging variable false, and resets the Z of the sprite to 1.  Since the drag might stop outside of any other sprite, or on the overlap of two sprites, we have to go through all the other sprites and check for overlap, using the procedure is_inside, collecting the result in local list landing_sprites.  If there are no landing sprites, there’s nothing to swap, and nothing to save.  We take the first landing sprite in the result list to settle any tie, and call swap_pictures to swap pictures with that sprite, and save_sprite_pictures to save the new picture order in TinyDB for any future load operation.  Either way, we snap the dragged sprite back to its original position using routine snap_back.


is_inside

This procedure tests if a dragged sprite is inside a target sprite, judging by the center of the dragged sprite and the four walls of the target sprite.  That comes out to 2 tests by X, and 2 tests by Y.


swap_pictures


This procedure swaps the Pictures of two given sprites.  It follows the common pattern of using a temporary variable to hold one of the swapped values, to avoid losing its value during the swap.


save_sprite_pictures


This works in the opposite direction of procedure last_save, taking all the Picture file names from all_sprites and building them into a list, then saving it in TinyDB under the PuzzleN/save tag for this puzzle.  


snap_back


This procedure snaps the given sprite back to the X and Y position where the drag started, as save in the two global variables dragged_start_X and dragged_start_Y.


When Hint.Click


The Hint button hides the playing area and shows the hint image and the count of correctly placed sprite Pictures, as returned by procedure completion_level.


completion_level


The completion level of a puzzle is the count of how many of its sprite pictures (last_save) match the end value from the JSON puzzle file.


match_count

This general purpose procedure will count how many items in one list match the corresponding position in another list.  Extra care is taken to not run off the end of a short list.


end

This procedure is similar to the hint procedure, getting the end branch of the current puzzle JSON pairs returned by the puzzle procedure.


This won’t work if the JSON file for this puzzle lacks the proper end tag and value.


When CloseHint.Click


This button hides the hint elements from the GUI and shows the canvas.


Gallery Link