hi, i mad a app where the ball has to detect if its touching the canvas background (light blue). the point of this app is to stay in a path (a white .PNG) i want to make it so when you get of the path, it will trigger a different screen. any ideas?
- stashu kozlowski
here are some screen shots of my code
--
as already recommended by Enis in your other thread is it possible for a sprite to detect is its touching a color?
"You need to check that color every time you move the sprite"
and some questions:
what is the timer interval of your clock?
what happens, if you set the ball manually to a x/y coordinate with the light blue background?
use Do it to debug your blocks
PS: please do not start a new thread next time, just continue the old thread if there are still issues
--
What I have done in an app like this (a bird flying through the sky) is to have a picture as canvas background image. In your case the blue color AND the white path. Then you can test for the canvas pixel color at a specific location, as in my example:
Where I test that the bird is still flying on top of my blue color (-18...) each time the timer event fires and if not, it must have hit something.
I think you can draw on the canvas and detect the drawn color, but if you have a sprite and your sprite is on top of that, you will see only the canvas color.
--
hey, sorry that i posted the same question in the forums. but i lost the link to the forum.
what is the timer interval of your clock? 90 (for the ball movement), 150 (for the background/path movement).
what happens, if you set the ball manually to a x/y coordinate with the light blue background? nothing. it suppose to open a "you lost" screen
is it possible if i turn my app to a .apk and you took a look for me.
the .png is just the white path. i need to make it so that when it touches the canvas (light blue)
--
You can append an .aia in this forum, but an .apk is prohibited.
I cannot promise that I will look at it immediately, but I will give it a try.
--
Thank you so much. i appreciate the help a lot.
there is no rush. after all your helping me :D
--
You made your life rather difficult by coding the whole app, having some wrong assumptions.
The way to do software development is to make something small first, make sure it works, and then add something and then another, until you are ready.
Incremental development this is called and with AI this is really easy to do because of the real time testing that you can do.
But in your case your ball is off the path from the start and therefore you jump to an end screen immediately, making any testing impossible!
So, start again, taking into account the following:
1. Although you can have a canvas of 4500 pixels, what you see is only as wide as your real screen, about 480 pixels on my phone.
2. So if you place a ball at x=2000, it is way out of sight.
3. Why do you have 3 timers? They will start interfering and for the buttons it would be much simpler to just use the button.Click event to move the ball up or down when the event happens. And the moving or having moved off the white path is easily combined. Which leaves you with only one timer and a more responsive game.
4. replace the open EndScreen with a notifier message until you have everything debugged.
5. Small thing: it is better to test whether the pixel color is not white, instead whether it is blue, because in the later case you could put some things on the canvas or give it other colors, etc.
And then, post on your progress!
--
Maybe I should apologize. After peeling of the things which made it impossible to debug your app, and when I corrected some problems, I understood what you were trying to do. And I think there is a problem. As soon as you enable the color detection, the sprite with the white path disappears. I will try to ask more knowledeable people.
--
Could you do something for me? Run the attached .aia and report what happens? On my phone the display freezes with the cyan background color after a second or so, but the staff at MIT do not have this problem.
Probably it is a weird timing problem, related to my phone and maybe also yours. PLEASE report your results.
You can fix the app by enabling the two disabled blocks in the Timer event block (it somehow solves the timing issue when you write something as label text in the timer event block). Then use the app as an example of much simpler way of what you want to do. As you can see you can move the path sprite by setting the right direction and speed in the designer and then you need only one timer.
--
댓글 없음:
댓글 쓰기