-
Notifications
You must be signed in to change notification settings - Fork 49
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
The bounds field of a Morph is a Rectangle but it is being used as a method #24
Comments
makes sense. Potentially a copy/paste error from https://github.com/jmoenig/morphic.js/blob/master/morphic.js#L2694 ? Did you find this by code inspection, right? I mean you didn't find this because of a runtime error doing something, right? (In which case I'd be curious how this was caused). |
I'm asking because it would look like that false-check of aRect is never triggered, otherwise someone would have caught this earlier. So if you didn't find this via runtime error then I'm guessing that this whole check could be removed. |
runs fine in my tests without that check, I took it away from Zombie Kernel. Keeping |
They are usable if you directly use Morph.prototype.drawOn.call(this, this.world().worldCanvas); The check is crucial in this situation (I use it often). |
Ah got it. that's a big repaint though. Why do you need to repaint the whole screen, out of curiosity? |
Because the method specifies the rectangle as being the bounds. The morph may be any size. |
I understand that. I don't understand where and why you are using it. The way you are using the morph would appear in front of everything, in the canvas. The overlaps wouldn't be managed correctly. Could you send me the link here on github to the piece of code where you invoke this without a rectangle, so I can figure out the context of what you are doing? |
right OK I took a look into your code Luis to get to the bottom of this - I see what you are doing here https://github.com/luismark/luismark.github.io/blob/master/starlings/starlings.html#L280 . You repaint the whole screen (and hence all the morphs in it) every ms here https://github.com/luismark/luismark.github.io/blob/master/starlings/starlings.html#L473 . It works for you, that's probably the thing to do in a sprite-based game where it wouldn't be worth to have dozens of small damage areas, so all is good, in general though in a desktop environment this would be a very slow repaint to do every frame. There is an easy way to achieve the same by just "damaging" the whole world, i.e. doing something like [whateverPointsToYourWorldMorph].changed() . This would create a huge damage rectangle on the whole screen and do the same of what you are doing now but without code changes. In that case it'd also be good to check that none of the morphs create further "damage rectangles" as those would be redundant and just slow things down - although Jens has added a routine that might be merging redundant rectangles together, I'm not sure. |
Yep, that's right, damaged rectangles that are "near" to each other get merged. I love your solution, @davidedc ! |
I'd like to use commit codes, like luismark/luismark.github.io@790546ca35ca instead of luismark/luismark.github.io:master to indicate code lines. |
I've got problems with my game! Please help me out, Jens! |
Hmm... sorry you're stuck. Can you explain what you're trying to accomplish that doesn't work the way you'd expect it to? |
See issues luismark/luismark.github.io#3 and luismark/luismark.github.io#4 to understand my problem. |
I noticed Morph.prototype.drawOn, that when aRect evaluates to false, it uses the bounds field as a method.
This must be fixed at line 2623 by removing the method call.
The text was updated successfully, but these errors were encountered: