2016년 11월 24일 목요일

Collide vs. Edge Reached


I am teaching an App course using APP Inventor. My students are making a PONG game. One of the students encountered this error. The ball hits the paddle, but the block executed is that the bottom edge reached. I changed canvas height, changed the when paddle.dragged/set y to startY to set y to canvas height - paddle height so it stays on bottom.  I put in a text label to see which block gets executed (when ball.edge reached if edge= -1 then text="edge reached" and also when collided with other then text="collided with". As you can see from picture, ball collided, but text says "edge reached" and game over...

No difference if played on emulator or phone/tablet.

Any suggestions would be greatly appreciated.


Auto Generated Inline Image 1 표시 중
I pl

--
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

Taifun

-- 

Good point. Sorry. I'm still new at this.
Here is most of the blocks:

Auto Generated Inline Image 1 표시 중
-- 
Maybe you need to raise the paddle away from the bottom edge more,
to give the paddle collision precedence over the edge bounce?

Try setting paddle Y lower by Ball1.Radius in the Ball1.Drag event?

ABG


-- 
Thank you. I tried it and it helped most of the time.
I set paddle.move to x= get currentX, y=canvas.height-paddle.height - ball.radius (so it is steady at @303 when canvas has height of 350)
When speed of ball gets too fast (above 50), then the event of edge reached is checked/called before ball collided event.
I have to look into what intervals the ball and paddle should be set to.
Thank you for your assistance.

Auto Generated Inline Image 1 표시 중
-- 

댓글 없음:

댓글 쓰기