pixi.js: how is the scrolling done on the website flashvhtml.com? - animation

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.

Related

Unity slider interaction with controller

So I have a laser pointer attached to my controller, shooting rays and triggering events whenever I press the tigger.
Tho it still has one or two buggs (Unity VR Controller UI Interaction), I have a more general question.
The UI needs some kind of slider. And I can't figure out how to make my pointer collide with the slider and behave in a slider-ish way. When I press my button, it currently ends up setting the slider to zero and not letting me drag it.
Thankful for any tipps on how to make them actually slide, since my ridgidbody-cube doesnt move and doesn't allow movement! Unitys documentation on e.g. the beginDragHandler isn't really helpful...
Cheers, Flo
If your enter/exit events already works, juste check the x (or the axis corresponding on your slider) of your "laser" every frame or so, and increase/decrease the value of the slider based on the delta between two check.
Hope it is clear, it should not be hard if you already have your events sets up !

Trying to add my animation to my idle state, but it just keeps saying "None(Motion)"

I have pulled the animation to the Motion tab both by dragging and trough the select motion search function but neither makes the animation stick to my idle state. Can someone give me a pointer to what im doing wrong?
One reason could be that the animations are marked as legacy.
Select one or many animation, in the inspector next to the lock, right click, then Debug. Untick the Legacy. No need to save or else.
The animation which you're trying to set is for another model!
You should use an animation that is for the model.
Or if you insist on using that animation select animation from assets and do a "Control + D" to duplicate it and use new one.
Use the Animator, not the animation controller. I made this mistake when I was following a tutorial. This is only relevant if you are animating .anim files within unity itself. Animation controller is the way to go if you import animations for your specific model.

isOpaque not stopping passing to parents drawRect

I got a problem with Cocoa and its View redraw hierarchy.
I'm currently testing displaying (audio) levels in a meter style control and I'm using the MeteringView class from MatrixMixerTest example project from apple. This class is drawing the meter and only drawing the difference what got changed which looks like a very efficient class.
My project is splitted into 2 splitviews, in some are NSCollectionViews (Scrollview, Clipview) and in others are only static views. If I add the meter to those "static" views they work fine when these views call setNeedsDisplay:YES. If a meter is added to the view of a CollectionView Item it gets rendered, but loosing its drawn "old level" parts and its corners/background. I think this happens because the CollectionView item gets also called to be redrawn (which has a background image) and everything is gone. It is drawing some parts whats currently changing (the drawing works).
Is there a way to prevent the Item itself to be redrawn? Or, I dont know why it is not happening in those static views, because those views also have background images but do not draw over the meter.
Are there some tricks or whats different in a CollectionView than in a "normal" view?
EDIT: After reading about isOpaque (MeteringView isOpaque = YES) means it should not call the parent views drawRect if set to yes. Well that works for the static views, those MeteringViews do not call parents drawRect, but those in a CollectionView do however. I dont know why.
EDIT 2: I gave this topic another title, because isOpaque=YES in MeteringView is not stopping calling the parents drawRect in a CollectionView, in a normal view it is working. Are there some things to know about? I have to stop redrawing the CollectionView Item because thats the problem.
Thanks in advance guys
Benjamin
isOpaque is just hint to the system. It does not prevent other views from drawing their contents, it only means that it can sometimes skip making other views update their contents.
If your view is opaque, it should draw itself as opaque and completely fill its bounds.

Changing selection state of IKImageBrowserView

Hey guys, I've just migrated my image selector from NSCollectionView to IKImageBrowserView. I've got almost everything set up the way I want it, except for the selection ring. I don't like the greyed out background that IKImageBrowserView defaults to, and I wanted to do a yellow stroke around the edge of my selected image to indicate it's selection (like in iPhoto). Is is possible to override the draw state of IKImageBrowserCell? I haven't been able to find any way to do it yet. It doesn't have the simple drawRect methods that I'm used to. Any help would be appreciated. I'm assuming I have to use CALayers?
I overrode - (CALayer *)layerForType:(NSString *)type and tried just as a test, setting the layer corner radius to 0, but it didn't seem to change anything. The method is being called because if I throw a breakpoint in it, it stops there. However, even if I return nil from that method, it still draws the images like usual.
Thanks!
That is the right method for customizing the IKImageBrowserCell.
Using CALayers and configuring different attributes, you can control many facets of how the images are presented.,
A layer of type = IKImageBrowserCellSelectionLayer is what you will want to change to have the display behave and present as you wish.
Here's a link to Apple's sample code project that will get you started

NSTextField on top of custom drawing - black outline and cursor not blinking?

I'm completely stumped with this problem. I made a custom search control that uses a few different classes. For some reason, when an NSTextField is anywhere over these different pieces, it displays a solid black border around it, and the cursor doesn't blink.
If anyone has a couple minutes - I've put together my code on pastebin.
Here's a picture of the search control, and what it looks like in this particular case:
The search control is sitting on top of a gradient view:
http://pastebin.com/m43fde2b6
The search control is pieced together with this code:
http://pastebin.com/m5be08c32
The actual graphical part of the search control is built from two classes:
http://pastebin.com/m5bfa9439
http://pastebin.com/m5e909a2f (extends above class)
I cannot find what the heck is wrong. The text works, but there's a black border, and the cursor doesn't blink. What am I doing wrong?
Arg, I've been pulling my hair out for days on this one.
Putting one view over a sibling view has never been well-supported in Mac OS X. Try making it a subview instead. You may even want to make it a private component of a dedicated search-field view.
On that note, is there a reason you're not using NSSearchField?
I got it figured out! Finally.
What I didn't realize was the the "drawRect:" method's parameter "dirtyRect", is the portion of the control that is "dirty", meaning it needs to be redrawn.
So, when an NSTextField is on top of a control, it will trigger that control's "drawRect:" to be called (3) different times - with different "dirtyRect" parameters.
1: the cursor - usually an NSMakeRect(textField.origin.x,textfield.origin.y,1,textfield.origin.height).
2: the text field frame
3: the size of the control the text field is sitting on.
So, the fix was simple, change my control's scale 9 drawing to always draw to [self frame]. You can see the change here: http://pastebin.com/m50a5b0ad (line 89).
Previously, it was drawing to the "rect" parameter (http://pastebin.com/m5e909a2f - line 88), but depending on where the drawRect call was coming from, the rect parameter was different sizes.

Resources