BenjaminDRichards

Members
  • Content count

    1
  • Joined

  • Last visited

About BenjaminDRichards

  • Rank
    Newbie

Recent Profile Visitors

1,604 profile views
  1. This sounds very similar to an issue that was raised elsewhere recently, so we have some good answers. The camera is actually a transformation matrix applied to the entire scene. You can rotate and scale it. You can scale it a different amount on different axes and then rotate it, causing shear. While you might never want to do this, it will make simple input mapping solutions break down and cry. Luckily, there are solutions. Camera.transformPoint( Kiwi.Geom.Point ) will take a point in screen space (such as input values) and tell you where that is in world space. There’s also an inverse, Camera.transformPointToScreen( point ), which may be useful for assessing whether an object is on screen or not. Finally, input components are available on Sprites, which send a Signal on input (sprite.input.onRelease.add(), etc). These do respond correctly to camera transformations, even the extreme sort with scaling etc. You can get a fair amount of data out of this. Basically, you pass a function to the Signal, and it’s called when that signal is triggered by the input system. A bare anonymous function with no parameters works fine, e.g. function() { Kiwi.Log.log( "#debug", "Input received" ); }. However, the input system will pass it a couple of optional parameters, which the function can use: a Sprite and a Cursor (just the sprite and cursor that are interacting, really). You can see these working in the console by adding parameters to the function passed to the signal: function( sprite, cursor ) { Kiwi.Log.log( "#debug", "Input received", sprite, cursor ); }. In particular, the cursor comes with a lot of data about its position on the screen, what modifiers are in use, how long it’s been down etc. Note that this information does not take any camera transformations into account, so it will still have to be transformed by the above methods; however, the camera is consulted when determining whether the cursor and the sprite interacted at all. Hope this helps!