treshaque

Members
  • Content Count

    2
  • Joined

  • Last visited

About treshaque

  • Rank
    Newbie
  • Birthday 01/01/1988

Profile Information

  • Gender
    Male
  • Location
    Limassol, Cyprus
  1. At the moment I use the following: function transformParentToChild( x, y, group ){ x -= group.x ; y -= group.y ; var sin = Math.sin( group.rotation ), cos = Math.cos( group.rotation ) ; var x_ = x * cos + y * sin, y_ = y * cos - x * sin ; return [ x_ / group.scale.x, y_ / group.scale.y ] ;}function transformScreenToGroup( x, y, group ){ if ( group.parent ){ var mid = transformScreenToGropup( x, y, group.parent ) ; x = mid[ 0 ] ; y = mid[ 1 ] ; } return transformParentToChild( x, y, group ) ;}...sprite.events.onDragStart.add( function(){ env.draggee = sprite ; }, this ) ;sprite.events.onDragStop.add( function(){ env.draggee = null ; }, this ) ;... var pos = transformScreenToGroup( game.input.x, game.input.y, env.draggee.parent ) ; env.draggee.x = pos[ 0 ] ; env.draggee.y = pos[ 1 ] ; ... Have I missed the standard way to transform world/screen coordinates to/from group?
  2. Hi everybody, Here's my problem. I have a group, which I scale or rotate. Now if I drag a sprite in it, the sprite moves totally wrong. Its shift is scaled and rotated too! var gr = game.add.group() ;var sp = gr.create( 100, 100, 'face' ) ;gr.scale.x = -2 ;sp.enableInput = true ;sp.input.enableDrag( true ) ; Say, if the group is flipped by group.scale.x = -1, the sprite motion will be mirrored: the sprite and the cursor go different directions. Looks more like a bug of dragging. I'd appreciate any practical advice or workarounds. I have a big tree of nested groups, do I need to implement a multistage cast of the input coordinates? Thank you.