Skip to first unread message

Fred Young

unread,
May 1, 2019, 3:15:29 PM5/1/19
to MIT App Inventor Forum
Hello,
I am building a game where all 16 sprites move together in a coordinated group.  When the right most sprite hits the right, I want all sprites to move left, and down 10 pixels.  The same should happen when the left most gets to the left... any ideas?

SteveJG

unread,
May 1, 2019, 3:35:57 PM5/1/19
to MIT App Inventor Forum
Depends on what you mean by 'move together in a coordinated group'  What right most hits the right means,  the dimensions of the Sprites etc.  A diagram would show what you intend. Something might be possible. You might be able to use the AnyComponent blocks to simplify the coding 


These are the controls and methods available to you 

This is how a Canvas works 

To get a Sprite to move based on what happens to another Sprite you would use

 MoveTo(number x, number y)

Moves the sprite so that its left top corner is at the specfied x and y coordinates.


Be aware, App Inventor processes commands asynchronously, so you cannot get all the sprites to move simultaneously.  They might move fast enough it does not matter. First move SpriteA down 10, then SpriteB etc.

Time for you to experiment, because only you know what you want to happen.

Regards,
Steve

TimAI2

unread,
May 1, 2019, 5:32:38 PM5/1/19
to MIT App Inventor Forum
Sounds like Space Invaders, try the Gallery for examples

Here is one:

Fred Young

unread,
May 2, 2019, 8:02:30 AM5/2/19
to mitappinv...@googlegroups.com
Thanks for the reply, it is like space invaders!  The example uses random movements,but I want coordinated "step movements" like the original space invaders game.

I have used the canvas and sprites before, so I have a pretty good idea how they work.  I'm trying to build a space invaders type game, where each clock timer fire (1000 ms), they all move 10 pixels to the right.  When the sprite to the right gets to the edge, they all move down 10 pixels and head to the left.  I dont think I can do all sprites, because my ship at the bottom needs to move independently, as does the missile... although I can use a ball sprite for the missile if need be. 

SteveJG

unread,
May 2, 2019, 9:11:52 AM5/2/19
to mitappinv...@googlegroups.com
You might try something like:

SpriteMove.PNG

...add 13 more sprites and you similarly move all 16 to the right with the Clock .... and add your  additional complexity.   Experiment.  When you get a solution, you might post it here in the Forum for others to share Fred.



Regards,
Steve

Fred Young

unread,
May 2, 2019, 9:18:21 AM5/2/19
to MIT App Inventor Forum
Yeah... I made "go right" "go left" and "go down" functions by setting all 16 sprites like that.  I'm working on trying to trigger each one based on the clock timer.  I'll keep playing and post a solution here.  I was just hoping a more efficient method existed that I wasn't seeing.

SteveJG

unread,
May 2, 2019, 9:52:29 AM5/2/19
to mitappinv...@googlegroups.com
Using Any Image Sprite you can do this (this uses a Button event handler rather than an EdgeReached...same principle)

SpriteMoveAnyComponent.PNG


I see no real advantage but you might experiment.     Good luck.

TimAI2

unread,
May 2, 2019, 10:50:13 AM5/2/19
to MIT App Inventor Forum
My link to the gallery was not much help
Attached a simple example with five sprites traversing the canvas and dropping down (and going back the other way)
The uses a counter as opposed to edge reached.
invaders.aia
Reply all
Reply to author
Forward
0 new messages