Jump to content

Thoughts of a Beginner


lithander
 Share

Recommended Posts

I'm programming a bit in Phaser for the first time now (new to JS too) and thought I'd collect my questions as they come up. I mainly post them here in the hopes that they will help you to see your framework from the "outside" perspective, figure out what topics could use more documentation etc.

 

 

Link to comment
Share on other sites

Picking

 

I spawned some circles (myGame.createGeomSprite(100, 100).createCircle(10)) and rectangles ( myGame.createGeomSprite(100, 200).createRectangle(10, 10) ) and would like to be able to pick them up and move them around. I registered a onDown handler on the input and now I'd like to figure out which of my object is under the mouse if any.

 

Only way I found out to do this is to call "geoSprite.circle.containsPoint" on all circles and "geoSprite.rect.containsPoint" on all rectangles. However the way I'd intuitively set it up I wouldn't know wether the object is a rect a circle or something else entirely and expect the object or some other part of the framework to handle the picking for me. If that's implemented somewhere I haven't found it yet.

Link to comment
Share on other sites

Picking II

 

myGame.createGeomSprite(100, 100).createCircle(100) creates a Circle that is centered at p(100,100) while myGame.createGeomSprite(100, 100).createRectangle(100, 100) creates a Rectangle that starts at p(100,100) and is centered at p(150,150) weird.

 

Also picking using the above mentioned contains() on the rect works as expected while the circle's does not. The circle is only pickable in it's west-north quadrant.

Link to comment
Share on other sites

Nice idea for a thread, thank you. By all means keep on experimenting and posting, but all of the things mentioned so far are fixed in the 1.0 release I'm working on like mad, including proper interaction support (click, tap, drag, drop, snapping) oh and I fixed the circle offset issue too :) By default Sprites are not going to be input enabled, you have to turn that on, but once done they'll interact to the mouse or any touch event.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...