Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Is Touching" behavior can be different on devices with different pixel densities/after going to full screen and back #656

Open
fsih opened this issue Jul 9, 2020 · 6 comments

Comments

@fsih
Copy link
Contributor

fsih commented Jul 9, 2020

This is the issue seen in #432, but the PR that was reverted did not fix the issue.

Expected Behavior

Load https://scratch.mit.edu/projects/409952654/editor/ on many devices
All devices should have the same behavior

Actual Behavior

Some of the devices say hello when you play the project, some don't

Steps to Reproduce

Load https://scratch.mit.edu/projects/409952654/editor/ and press the green flag
in particular, my mac 15" mid 2015 version (battery explosion version) says hello
chris's windows 10 chrome with device pixel ratio 1 does not say hello. If he goes fullscreen and runs it, then it says hello.

Operating System and Browser

e.g. Mac OS 10.11.6 Safari 10.0

@BryceLTaylor BryceLTaylor changed the title Is touching behavior can be different on devices with different pixel densities/after going to full screen and back "Is Touching" behavior can be different on devices with different pixel densities/after going to full screen and back Jul 9, 2020
@BryceLTaylor
Copy link

@fsih Do you have an idea of which types of devices have undesirable behavior? We're trying to get an idea of impact.

@fsih
Copy link
Contributor Author

fsih commented Jul 9, 2020

@BryceLTaylor we think that all devices should probably act as if isTouching and isTouchingColor are being run on a 480x360 sized project screen. In that case the devices with device pixel ratio = 1, at normal screen size, are the only ones doing the right thing right now (the cat does not say hello in the touching bread project) and all higher dpi devices, and any device that has been put into fullscreen mode, or was previously in fullscreen mode, is doing the wrong thing (the cat says hello as it passes the bread)

What's the right behavior is up to us to decide though. If you can see some of the pixels of the cat touching the bread when it's at full screen, but not when it's in normal screen size mode, should the cat always say it's touching the bread, even if it means projects behave differently on different devices?

@adroitwhiz
Copy link
Contributor

IIRC we actually figured out that the cat should always count as touching the bread (at least, it does on my branch), but somehow does not currently. At the very least it should count as touching the bread when you use the "touching sprite" block

@griffpatch
Copy link
Contributor

griffpatch commented Jul 9, 2020 via email

@fsih
Copy link
Contributor Author

fsih commented Jul 9, 2020

@adroitwhiz's branch is fixing some issues with isTouching, but I think with the isTouching code as it is now, we want everything to match the case on a 1:1 device pixel ratio with normal sized screen case, where the cat doesn't touch the bread

@AmazingMech2418
Copy link

Would it be viable to refactor the collision algorithm to transfer the drawable to a 480x360 non-displaying canvas element that is used specifically for the collision algorithms? Canvas size in pixels is clearly the issue here, and of course, it would not be ideal to change the entire rendering system to use only 480x360 since it would ruin image quality, but for collision detection, it might work. Not sure on the impacts on performance though... But all that would be needed is to transfer the drawable to a 480x360 canvas and then use that canvas to determine if the drawable is touching each point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants