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

Center anchored actors are not drawn at correct canvas coords when scaled #618

Closed
kamranayub opened this issue Aug 4, 2016 · 1 comment · Fixed by #619
Closed

Center anchored actors are not drawn at correct canvas coords when scaled #618

kamranayub opened this issue Aug 4, 2016 · 1 comment · Fixed by #619
Assignees
Labels
bug This issue describes undesirable, incorrect, or unexpected behavior
Milestone

Comments

@kamranayub
Copy link
Member

Steps to Reproduce

  1. Create an Actor (0, 0, 10, 10)
  2. Scale the Actor by 2x
  3. Set Actor.anchor to 0.5
  4. Add Actor to game

Expected Result

When drawn, Actor should be twice as big (20x20) centered on (0, 0)

Actual Result

Actor is drawn at proper scale but off-center as shown here:

image

The Green square is a 2x actor centered on (0, 0) and should perfectly contain the red and blue squares.

Environment

  • browser: Chrome
  • browser version: 51
  • operating system: Windows 10 x64
@kamranayub
Copy link
Member Author

I added a new visual test for testing anchoring with fillRect and Sprite drawing. It's a mess in the current version, as you can see:

Yuck

The anchor is being double-scaled and sprite drawing is super weird even with setCenterDrawing to false for everything except the center test.

After making some changes to the draw call logic, I believe I've fixed it properly:

image

I removed all the center drawing cruft, since now it will properly draw anchored correctly.

I'll submit a PR with the change.

@jedeen jedeen added this to the 0.7.0 Release milestone Aug 8, 2016
@jedeen jedeen added the bug This issue describes undesirable, incorrect, or unexpected behavior label Aug 8, 2016
eonarheim pushed a commit that referenced this issue Aug 18, 2016
* Add visual anchoring tests to showcase issue
* Add all visual anchor tests
* Fix Actor drawing incorrectly with scaling + anchoring
* Compile dists
* WIP anchors test and sandbox
* Compile dists
* Add anchor visual test to test menu
* Make spriteOffset the same as actor.anchor
* Remove image padding on heart.png
* Fix anchor based translation error accumulation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue describes undesirable, incorrect, or unexpected behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants