AppInventor Collision Detection

418 views
Skip to first unread message

Ethan Bowering

unread,
Apr 27, 2016, 8:39:27 PM4/27/16
to MIT App Inventor Forum
Hi, I just need help with a small thing.

I'm making a maze game in Appinventor and what I need is for the sprite you move through the maze to stop moving once it touches another sprite, in this case a wall. Does anyone know how to do this? 

Thanks in advance

Taifun

unread,
Apr 27, 2016, 8:52:15 PM4/27/16
to MIT App Inventor Forum
please first check these maze threads https://groups.google.com/forum/#!searchin/mitappinventortest/maze%7Csort:date and in case these do not help, then ask again
Taifun

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

ScottFerguson

unread,
Apr 27, 2016, 9:24:50 PM4/27/16
to MIT App Inventor Forum
Another possibility is to check if any of the pixels just outside of the boundary of the sprite is the wall color, if so, then you are touching one or more walls.
For that you would likely use the canvas GetBackgroundPixelColor method.

Ethan Bowering

unread,
Apr 30, 2016, 2:34:12 PM4/30/16
to MIT App Inventor Forum
Thanks, I'll try that. Also, I'm trying to get my character to keep moving until the button is released, instead of just moving a bit every time I press the button. Any sugestions?

ScottFerguson

unread,
Apr 30, 2016, 3:54:23 PM4/30/16
to mitappinv...@googlegroups.com
Set the character sprite's initial Speed to 0.
Set the character sprite's initial Heading to the direction you want it to move.

Inside the button TouchDown event block, set the character sprite's Speed property to a non-zero positive value. 

Inside the button TouchUp even block, set the character sprite's Speed to 0.

You will also want to change the character sprite's Interval from 1000 to 100 for smoother movement, most likely.

Ethan Bowering

unread,
May 1, 2016, 2:02:07 PM5/1/16
to MIT App Inventor Forum
Thank you so much! That is exactly what I needed.

Ethan Bowering

unread,
May 1, 2016, 2:48:24 PM5/1/16
to MIT App Inventor Forum
One last question, how do I use this block? I don't know what I'm supposed to attach it to, and what to do with it afterwards.
Reply all
Reply to author
Forward
0 new messages