Note that there are some explanatory texts on larger screens.

plurals
  1. POAS3/AIR Mobile Click and/or touchevents on moving objects
    primarykey
    data
    text
    <p>few weeks ago i asked a question about a similair issue, but within the Starling Framework (<a href="https://stackoverflow.com/questions/16857841/starling-touchevent-on-sprite">Starling TouchEvent on Sprite</a>)</p> <p>Now, i am working on another mobile app/game with Away3d. I seem to have the same problem touching/tapping a moving sphere or box. When the sphere is not moving, i can just tap it exactly at its position, but when it rotates, the click-event doesnt fire very accurate. this only happens on Mobile (tested on Android 4.2.2: Nexus7/Galaxy S2 and iOS: iPad2/iPad Retina)</p> <pre><code>package { import away3d.containers.ObjectContainer3D; import away3d.containers.View3D; import away3d.core.pick.PickingColliderType; import away3d.core.pick.PickingType; import away3d.debug.AwayStats; import away3d.entities.Mesh; import away3d.events.MouseEvent3D; import away3d.primitives.SphereGeometry; import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event; import flash.geom.Vector3D; [SWF(frameRate="60")] public class Main extends Sprite { private var _container:ObjectContainer3D; private var _view:View3D; private var _sphere:Mesh; public function Main() { super(); addEventListener(Event.ADDED_TO_STAGE, onAdded_toStage); } private function onAdded_toStage(e:Event):void { removeEventListener(Event.ADDED_TO_STAGE, onAdded_toStage); stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; stage.addEventListener(Event.RESIZE, onResize_stage); init3d(); } private function onResize_stage(e:Event):void { _view.width = stage.stageWidth; _view.height = stage.stageHeight; } private function onEnter_frame(e:Event):void { _container.rotationY += 1; _view.render(); } private function onClick_sphere(e:MouseEvent3D):void { //reposition the sphere var deg:Number = Math.random() * 360; _sphere.x = 250 * Math.cos(deg); _sphere.z = 250 * Math.sin(deg); _sphere.y = 80 + (Math.random() * 40); } private function init3d():void { //create the 3d-view _view = new View3D(); _view.width = stage.stageWidth; _view.height = stage.stageWidth; addChild(_view); //create a cub _view.camera.z = -400; _view.camera.y = 75; _view.camera.lookAt(new Vector3D(0, 125, 0)); //create container _container = new ObjectContainer3D(); _view.scene.addChild(_container); //create sphere to tap _sphere = new Mesh(new SphereGeometry(10)); _sphere.pickingCollider = PickingColliderType.AS3_FIRST_ENCOUNTERED; _sphere.y = 100; _sphere.z = -250; _sphere.mouseEnabled = true; _sphere.addEventListener(MouseEvent3D.CLICK , onClick_sphere); _container.addChild(_sphere); var stats:AwayStats = new AwayStats(_view); addChild(stats); addEventListener(Event.ENTER_FRAME, onEnter_frame); } } </code></pre> <p>NOTE: i also tried different framerates, more events(Mouse_up, down etc), different pickers.</p> <p>As this problem also happens with 2d moving sprites (in starling) my guess is that is might be Stage3D or AIR related, instead of starling/away3d.</p> <p>Anyone has some suggestions? Maybe i'm forgetting to set something in the app.xml?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload