Skip to first unread message

onursa...@gmail.com

unread,
Jun 21, 2014, 6:53:38 PM6/21/14
to mitappinv...@googlegroups.com
Hello,

I would be grateful if you could help me on my uncompleted game on App inventor 2. My problem is that there is 1 ball at the beginning of the game and I want this ball to copy itself in every 5 seconds. Or do not copy, just I want new balls which are coming from the top of the screen in every 5 seconds. Could you please show me how to draw the blocks to achieve the project.

Thanks in advance.

M. Onur Sagaltici

SteveJG

unread,
Jun 22, 2014, 9:25:44 AM6/22/14
to
If you share some blocks (as a png of jpg) image) of what you tried, perhaps someone will help.

I assume you have a sprite   called  ball.png      .   You are going to have to have a timer in the Clock telling to add a ball every five seconds... 5 seconds is equivalent to 5000 ms, so you will have to set the interval trigger for the Clock to  set Clock.TimerInterval to 5000 .  Then you will have to put some code in the  when Clock.Timer do block  to place a new ball on the screen.

Hints:    You will probably use the ImageSprite blocks a lot.... for instance to image Image.Sprite.Visible to true    or   false to make a new ball appear or disappear,   You will use ImageSprite.MoveTo      and other controls.

Unless someone posts an example, you will have to figure out the details yourself.    You can get ideas from some of the games in the App Inventor Gallery http://gallery.appinventor.mit.edu/#page%3DHome  ; these apps include source code (although many are AI Classic)..   Write a simple app with only the sprite actions in it and experiment.  It is how experienced programmers figure out how to do things they have never done before.

Others may provide additional suggestions or code; I hope this will get you started.   I have not tried to do what you want to do, but it certainly seems possible.

Regards,
Steve

Taifun

unread,
Jun 22, 2014, 10:51:46 AM6/22/14
to mitappinv...@googlegroups.com
 just I want new balls which are coming from the top of the screen in every 5 seconds.
you can't create new components during runtine, therefore you have to define all the balls you need and set them to visible = false
then as soon as you need them, set them to visible = true
Taifun

Trying to push the limits of App Inventor! Snippets and Tutorials from Pura Vida Apps by Taifun.         

Abraham Getzler

unread,
Jun 22, 2014, 12:12:03 PM6/22/14
to mitappinv...@googlegroups.com
You will also need a few lists to keep track of the balls in their various stages of life ...

  • BallsInStock   (fill it at Screen1.Initialize or game start)
  • BallsInPlay  (initially empty)
  • BallsExploding
  • etc.

ABG


onursa...@gmail.com

unread,
Jun 22, 2014, 12:43:01 PM6/22/14
to mitappinv...@googlegroups.com
Thank you all for your prompt responses. Now, my question has been clarified.

As far as I understand, there is no way to copy the ball during runtime. Basicly, I will add new ballSprites (initial visibility = false) and make them visible one by one in every 5 seconds. 

For helping to other users, I am going to add the blocks after setting the balls.

Best regards,

Onur
Reply all
Reply to author
Forward
0 new messages