danksch

Members
  • Content Count

    10
  • Joined

  • Last visited


Reputation Activity

  1. Like
    danksch got a reaction from Deltakosh in Convert space to screen coordinates   
    For whatever reason, it works now. I can't say why; I changed a couple of things in between and lost track of the things I've altered; been coding for too long non-stop now.
    I'm accessing the viewport via scene.activeCamera.viewport, which results in screen coordinates between 0 and 1. 
    To get pixel values in order to place my Text2D or Shape2Ds, I do
    for anyone who's interested. 
     
  2. Like
    danksch reacted to Deltakosh in Update Text2D in Canvas2D   
    Hello you should consider using Babylon.GUI instead: http://doc.babylonjs.com/overviews/gui
  3. Like
    danksch got a reaction from Wingnut in Problem with animation action   
    Thanks for the fast and productive answer, fixed it right away!
  4. Like
    danksch reacted to Wingnut in Problem with animation action   
    http://www.babylonjs-playground.com/#2CFAMI#14
    Hi danksch... there ya go, that should work.  Good test scene, by the way.
    Look at line 35.  See BJS_event (any name will work).  It is a special event object that arrives automatically in executeCodeAction functions.
    If you examine that event object, you'll see...
    Object { source: Object, pointerX: 494, pointerY: 109, meshUnderPointer: Object, sourceEvent: pointerdown, additionalData: undefined }
    In line 38, we make tile = the meshUnderPointer.  Works gooooood.  Hope this helps.  Party on!
  5. Like
    danksch got a reaction from Wingnut in Block input action while animation is played   
    Hey @Wingnut,
    thanks for the thorough answer (plus the playground), I really appreciate it! 
    Your solutions make sense; actually, I've already been using the callback-argument to resume the idle sprite animation. Just didn't think about switching a boolean on and off...well, sometimes it's the simple things.
    Thanks again!
     
     
  6. Like
    danksch reacted to Wingnut in Block input action while animation is played   
    Hiya @danksch, welcome to the forum.  Let's tour THIS playground:  http://www.babylonjs-playground.com/#9WUJN#22
    First, you should know that this was ORIGINALLY a 180 frame animation, but I added 5 more frames in lines 37-40 (box does not change position at all during that 5 frames at the end). 
    I do this...  because we are about to put a BABYLON.AnimationEvent on frame 180.  BUT, a 0-180 frame animation... might never "land-on" frame 180.  Often, the last frame is 178.6 or 179.2, etc.  An animationEvent placed on frame 180... might never occur. 
    Now you know WHY I added some frames BEYOND the AnimationEvent on frame 180.
    Watch the JS console.  You'll see the AnimationEvent (from lines 45-48) report to console near/at the animation ending.
    There is ANOTHER way... a "callback" called 'onAnimationEnd'.  It is available as a final arg/parameter in line 61... scene.beginDirectAnimation().  This calls my onAnimationEndFromCallbackFunc()... in lines 54-57.
    Okay, NOW you have TWO different types of "triggers/actions" that signal the end of an Animation.  What can you do with it?
     
    Well, you spoke-of stopping keypresses during animation runs.  BUT, WHAT IF, instead, you block startMyAnimation()... IF boolean flag OkToStartAnim... is set false? 
    Begin by using a function to START your animation (perhaps called from within your keyDown handler func).  Example:
    var startMyAnim = function() { if (OkToStartAnim) { scene.beginDirectAnimation(blah, blah, blah); OkToStartAnim = false; } }; As soon as you start your animation, ALSO set global OkToStartAnim flag...  to false.  If OkToStartAnim is false, the user can do keypresses until they go crazy, but no repeat-starting of THIS animation. 
    Using EITHER method of "my animation has ended", you can set your OkToStartAnim = true;  THEN the user will be able to start a "repeat" animation.
    SO... OkToStartAnim is this one animation's "starter lock", right?  You can use EITHER of the end-of-animation handlers to toggle that boolean lock.  With me?  I hope so.  Holler if you have any questions.  Party on!