In the example below,
OnTouchEffectAction contains canvas.InvalidateSurface().
OnCanvasViewPaintSurface contains convas.DrawPath().
Questions:
Why OnTouchEffectAction requires InvalidateSurface()?
Why doesnt call InvalidateSurface after
drawing?
Complete Code is given here
InvalidateSurface causes the PainSurface event to be raised, which calls OnCanvasViewPaintSurface. InvalidateSurface is how you tell Skia that you've made changes to a canvas and that it's UI needs to be refreshed. OnTouchEffectAction is adding new polylines to the canvas, so calling InvalidateSurface causes the canvas to be redrawn with those new lines.
Related
I have two canvases and two stages in CreateJS / EaselJS. The first stage has autoClear set to false and I am doing dynamic drawing on it starting with a stagemousedown event. The second stage uses nextStage to send mouse events to the first stage. The second stage has interface such as a Bitmap that I want to press on to go to another page. When I click on the Bitmap, the stage beneath does the dynamic drawing. I want the click on the Bitmap not to go through to the first stage but stopImmediatePropagation does not work, nor does putting a clone of the Bitmap with mouseEnabled false on it underneath. I can just use mousedown on the Bitmap so the user does not notice as much, but was wondering if there is a way to disable mouse events from passing through the top stage if they are acting on an object with an event set to capture? Thanks in advance.
The stagemousedown and other stage events are decoupled from the EaselJS object event model. They are catch-all events, which basically represent mouse interaction with the . Because of this, catching and stopping these events won't interrupt the display list hierarchy.
Typically if you want to block other events in the same stage, you can create a canvas-size box (Shape, etc) that will block the interaction. When dealing with nextStage, this is especially true, since we are passing on events that are unhandled by objects in the EaselJS display list.
A better approach might be to toggle the nextStage on stagemousedown, so it is null during the click event. Not sure if this will work, but its a start.
I have a button under a canvas that is suppose to restart the scene. But instead its not calling the intended function of attached script.
On Unity Forums, I found solutions like it should be at higher hierarchy in canvas, and the canvas should have a graphic raycast and so-on.
But it still isn't working, although its on click array detects the intended method it is suppose to call.
Scene Editor with Canvas Selected:
Scene Editor with Button Selected:
Remove the canvas component from your button.
Make sure that there is a GraphicRaycaster on your canvas, and that there is an EventSystem object somewhere in the hierarchy.
(Both should have been added when you first added the canvas, but things get lost)
The screenshot that shows your button being selected, also shows, that you did pick a gameobject for the OnClick event, but you didn't pick a function from the drop down right next to that field, it says no function.
Instead of selecting the C# class, select the GameObject that
btnSceneSelect is attached to.
If btnSceneSelect is not attached to a GameObject, attach it to one
(other than the button).
Taken from this site
How's the page scrolling created on flashvhtml.com? How is the scrolling triggered by the links at the top and how the other 'sub animation' events tied in to the scrolling background?
This is what I have been able to gather:
Listeners for interactions are added in the Trackpad.js file. Listeners for events such as mouse dragging, keyboard events, touch etc. All of which calculating a value variable.
This value variable of the Trackpad.js is then
used to adjust camera position in the update method of main.js
file.
There are 3 main views that are being rendered if I understand
it correctly: ScrollView, ScaleView, RocketView. All of those
initiated inside the init method of main.js. But they are all
defined in the fvh.js file.
Each of these three views have an
updatePosition method taking camera.y or mainScrollPosition as
parameter. These updatePosition methods are called inside of the
same update method of main.js file.
Then there is a ScrollMap.js which contains loads of position data for all 3 views e.g. it contains ScrollView data in the format of:
mcxxx:{view:'nameofelement',depth:xx,startFrame:xxx,endFrame:xxx,position:[xxx,...]} etc.
Also there is a sectionLandPositions variable defined in the main.js file which is also very interesting because this is what is then used inside the onMenuItemPressed method in the same file to tween and bring a certain section into view.
So magic basically happens in the updatePosition methods of each views and how the value is computed in the Trackpad.js. And this is where I leave you to debug further and take it home. :)
Files under scrutiny are: Trackpad.js, fvh.js, ScrollMap.js, main.js. Hope you find it all useful.
P.S. Kudos to Waste-Creative for creating this informative and engaging website.
T
An easy way to do this, is by adding tweens and then using the scroll/drag input and links to move around in the tween's timeline.
Tween one : Pans Camera down slowly continuously.
Tween two : Wait's until x, fades sprite in untily y, fades sprite out, ..
Make sure, you dont 'play' the tween's after creating them, but adjust the time manually (based on the scroll position).
There are a few tweeing frameworks you can use for pixi: Greensocks, Impact, tween.js
And there's a discusion on it over at the html5gamedevs forum.
KineticJS seems to have an issue with handling clicks on background layers after redrawing the stage.
I have a jsfiddle with a minimal example of this problem. http://jsfiddle.net/Z2SJS/
On line 34 I have:
stage.draw()
If this is commented out, events fire as they should. When this is present, after dragging the click events to the background will stop firing.
I know that in this example I am not doing anything that would require me to redraw the stage, but in my project I am using the dragstart and dragmove events to manipulate objects on multiple layers, and I then lose reference to my background clicks.
Is there something I need to do to ensure that redrawing the stage does not cause my events to stop firing?
Instead of using stage.draw() use foreground.draw()
here is the updated fiddle
Alternately: set dragOnTop: false inside the circle instantiation. Fiddle2
In this thread, Mike Bostock explains that setting a brush's extent and redrawing the brush are two separate operations. I understand this, but I'm having trouble working out the details.
He says you need to do something like the following:
brush.extent([0.2, 0.8]);
svg.select(".brush").call(brush);
However, when I execute call(brush), it simply draws the brush rectangle on the new extent. The 'focus' chart never gets updated. However, if I call my brushed function (the function that I assigned to my brush), it works.
It seems like call(brush) doesn't execute brushed. How do I get it to execute this function?
UPDATE: Here's a fiddle with my code. When you run it, notice the brush is correctly drawn, but the focus is not updated. Uncomment line 180, and the focus gets redrawn too.
(Of course, eventually I will want to do this from outside the chart object, but for now I am doing it within just to try to figure out what's going wrong.)
Essentially, I'm asking: How can I trigger the brushed function from outside the object? How does the brush event handler do it?
Setting the extent of a brush explicitly doesn't trigger the event that causes the function associated with it to be called. In this case the simplest solution is to, as you already found out, call brushed() explicitly after setting the extent.