Help me think through a logical way to implement the desired effect.
Goal: (I'm using Adobe Animate CC 2017 targeting AIR for Desktop)
- Move a sprite using a controller (mouse on a PC for instance) with a 1:2 ratio.
- Have an event trigger a function that causes this relationship to become a -1:2 ratio (and another one to switch it back to 1:2)
My First Thought Experiment (represented in pseudo code)
sprite.x = mouse.x * 2 - stageWidth / 2 - sprite.width / 2
(works fine, 1:2 ratio)function
reverseRatio():void{ sprite.x = stageWidth - (mouse.x * 2 - stageWidth / 2 - sprite.width / 2) - sprite.width
(also works fine, but with a catch*)- The "catch" is that the sprite, when triggered to reverse ratios, jumps to the reverse side of the display window. What I'd like to accomplish is somehow have the motion of the sprite tied to the motion of the mouse, but what I have accomplished is the position of the sprite is dependent on the position of the mouse. And since when this event is triggered, the mouse does not move, the sprite suddenly does (which I'm guessing would get bad reviews during play testing, although the very saddistic gamer may actual enjoy trying to master this effect!)
So it seems I need to do just that, link the motion of the mouse and sprite, instead of the position. This also seems to have a "catch" though.
Here's another thought experiment using this motion dependency method.
- You move the controller toward the right of the display window with a motion dependency to the Sprite of 1:2 (mouse:sprite). *By motion I mean use the delta or change in x position by recording the position in one frame and using the difference in the next frame to determine how much the Sprite translates.*
- The Sprite goes to the far right of the window as well (actually getting there before the mouse does because of the imbalanced ratio).
- The event is triggered that negates the relationship to -1:2 (mouse:sprite).
- The sprite does not jump to the far left side of the window because its motion is dependent on the motion of the controller, which isn't being moved.
- Now the controller moves further to the right
- This should have the effect of moving the sprite to the left, which it does, but by the time the sprite moves back to the left half way across the screen, the controller has left the window and thus can no longer influence the sprite (my application pauses when the mouse leaves, because my target framework doesn't support mouse input from outside the display window).
So because these two methods have these "catches" I have to choose between the sprite jumping across the screen or only being able to move the sprite halfway back when this event is triggered. I think this means I need to really rethink my whole methodology. Any thoughts on a slick way to achieve this effect? It seems impossible to me without having my PC physically move the location of the mouse cursor (which, if I could do that, would totally work!).
Thoughts? Questions?
in the bottom picture, the event has been triggered, but the sprite can't respond to the movement of the cursor, becasue it is already to the far right. I could manually move the cursor to the far left, at which point things would work fine, but the goal is for this to be instantaneous reversal of the relationship.
edit
If I were to port this to iOS, I think I could use the accelerometer to control the Sprite which effect could be instantaneously reversed without a cursor running out of real-estate. Right? What about using a finger drag to control the Sprite? Would I run into the same problems as the mouse on a desktop? Just musing here.
update
I have an idea (just to give you an idea of the kind of ideas i am open to for suggestions). My idea is give a visual cue as to where the Sprite would "jump" to when the correlation gets reversed. I am imagining a ghost image, or an outline, or a Sprite with raster lines through it to indicate that it is an inactive version. Then when the correlation switches, the feint one becomes solid and vice versa.