-
Notifications
You must be signed in to change notification settings - Fork 73
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
Private object variables accessible from outside. #46
Comments
Thanks for the detailed feedback! You make several good points. Private variables To a small degree Sprite has the same "problems". Where it's possible to directly do for example "sprite.image = an_image;" but the recommended way is using sprite.setImage(an_image) since then jaws can run code to recalc the bounding box and so on. What I ended up with in the Sprite-constructor was Both ways. There's (chainable) setters for everything. But you could also go low-level and modify for example x and y directly if you want. I haven't decided yet if I should dump the priv var access and go 100% with chainable setters. Or at least rename all private variables, so it's sprite._x = 100 instead sprite.x = 100 .. as an extra security measure but also point out "Now you're modifying something private!" Jumping mid air after walking off a ledge Rect.js function parameters Examples index.html Offline development |
Thanks for the response, ippa. That clarified things. sprite._x sounds like a decent idea. At least that communicates somewhat that it's supposed to be private. Thanks. |
Hi ippa, here are a few things I noticed. I could open new issues for each if you want.
Private variables
Assigning to a rect's x/y does not alter right/bottom. This creates problems like tile_map.atRect(rect) not working due to right/bottom being off. I imagine x/y are supposed to be private. Is it possible for jaws' current design to accomodate private object member variables?
I worked around it by calling moveTo() every update() with the rect's current x/y.
Jumping mid air after walking off a ledge
Example 9 (the side scrolling platformer) uses the can_jump variable, which is assigned true when the player collides with the ground. The player is therefore able to jump in midair after falling from a ledge, because can_jump is still true.
I added a feet_rect under the player that "attaches" to his feet. I then added a canJump() function to check if the feet_rect is colliding with something. So the player only jumps when his feet are in contact with something.
Jaws side scrolling platformer example 9 "fixed"
Example 9 JavaScript gist "fixed"
Rect.js function parameters
Rect.js uses raw function parameters instead of an option object like most of the other classes. I'm not sure why this is the case.
Examples index.html
Being able to navigate the examples would be convenient. Maybe a link back to the index from each example, or even a table of contents.
Offline development
Chrome offline development is hairy due to XSS. Firefox 11 is happy to run them offline though. I'm not sure what can be done about this besides informing devs how to work around the inconvenience.
Tell me if anything is unclear or if you need more info. If none of these are of concern then I'll leave them be.
Thanks!
The text was updated successfully, but these errors were encountered: