Apply tint filter to object with code in Animate CC - createjs

I'm using Animate CC 2015 and publishing to Canvas.
Can anyone tell me how to apply a tint to an object on my timeline?
The object has been placed there manually and has an instance name. I simply want to change it from white to red using code that runs in the first frame.
On a related note, do you know of a good JS language reference for Animate CC? I always seem to end up on Actionscript references or the CreateJS site which doesn't cater well for stuff that is created manually on the timeline.
Cheers

Have you applied a tint already in Animate? Filters in Canvas are particularly expensive, so by default, Animate will cache items that have filters applied. You have a few options:
Every frame, cache the symbol again. This can be very expensive, but it will work.
Instead of transitioning a single filter, cross-fade between a filtered and non-filtered object. This looks very similar (especially with a tint), and has no performance concerns.
As for JavaScript reference, what exactly are you looking for? Mozilla's MDN reference tends to be the goto place for our team when it comes to raw JavaScript. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
Cheers.

Related

NSCollectionViewItems shaking and with X to remove

On Launchpad we have basically a big collection view with app icons. When you hold an app (press down with the cursor and don't stop) for a very long time, all the icons start to shake, and a little 'x' appears in the top left hand corner of each one of them, which makes removing items very easy.
I would like to know if there is some method already implemented in the API which allow us to reproduce that same behavior in a regular NSCollectionView.
I've checked NSCollectionView and NSCollectionViewDelegate documentations in Apple's Mac Developer Library, however I haven't seeing anything related to that. Should that be done manually? If so, how can I make the collection view items shake?
There is no existing method to do this, but you can recreate it with Core Animation.
Providing the full code to do that is beyond the scope of Stack Overflow (and would be highly dependent on your existing code), but a CABasicAnimation affecting the transform.rotation key of the layers of your NSCollectionViewItem views should put you on the right path.

Kivy: Depth Oder not so in Depth

Now I could be wrong about this but after testing it all day, I have discovered...
When adding a widget and setting the z-index, the value "0" seems to be the magic depth.
If a widget's Z is at 0, it will be drawn on top of everything that's not at 0, Z wise.
It doesn't matter if a widget has a z-index of 99, -999, 10, -2 or what ever... It will not appear on top of a widget who's z-index is set to 0.
It gets more strange though...
Any index less than -2 or greater than 2 seems to create an "index out of range" error. Funny thing is...when I was working with a background and sprite widget, the background's Z was set to 999 and no errors. When I added another sprite widget, that's when the -2 to 2 z-index limitation appeared.
Yeah I know...sounds whacked!
My question is, am I right about "0" being the magic Z value?
If so, creating a simple 23D effect like making a sprite move being a big rock will take some unwanted code.
Since you can only set Z when adding,a widget, one must remove and immediately add back, with the new Z value...a widget.
You'll have to do this with the moving sprite and the overlapping object in question. Hell, I already have that code practically written but I want to find out from Kivy pros, is there a way to set z-index without removing and adding a widget.
If not, I'll have to settle for the painful way.
My version of Kivy is 1.9.0
What do you mean by z-order? Drawing order is determined entirely by order of widgets being added to the parent, and the index argument to add_widget is just a list index at which the widget will be inserted. The correct way to change drawing order amongs widgets is to remove and add them (actually you can mess with the canvases manually but this is the same thing just lower level, and not a better idea).
I found a working solution using basic logic based on the fact widgets have to be removed and added again in order to control depth/draw order.
I knew the Main Character widget had to be removed along with the object in question...so I created a Main Character Parent widget, which defines and control the Main Character, apart from its Graphic widget.
My test involves the Main Character walking in front of a large rock, then behind it...creating a 23D effect.
I simply used the "y-" theory along with widget attach and detach code to create the desired effect.
The only thing that caught me off guard was the fact my Graphic widget for my Actor was loading textures. That was a big no no because the fps died.
Simple fix, moved the texture loading to the Main Character Parent widget and the loading is done once for all-time.
PS, if anyone knows how to hide the scrollbars and wish to share that knowledge, it'll be much appreciated. I haven't looked for an API solution for it yet but I will soon.
Right now I'm just trying to make sure I can do the basic operations necessary for creating a commercial 23D game (handhelds).
I'm a graphic artist and web developer so coming up with lovely visuals won't be an issue. I'm more concerned with what'll be "under the hood" so to say. Hopefully enough, lol.

Dynamically changing content of UIScrollView

I'm trying to create a menu for a local multi-player game that dynamically updates when peers become available on the network.
The interface I want to implement is a UIScrollView, where each page displays information about a peer. Ideally, these pages are added and removed when a peer's availability changes.
I have looked through several tutorials using UIScrollView, but they all seem to pull page information from a plist or pre-loaded array.
What I want must be possible; weather app behaves in a similar manner, dynamically adding or deleting location pages. I'm not sure where to turn for further help, though. How do I dynamically update my scroll view's contents as outside events occur?
I decided to go with UICollectionView instead, it seems to provide a better method of implementation for what I'm trying to accomplish. Thanks!
Have a look at this Ray Wenderlich Tutorial.
I've used it as a basis for doing a paged scroll and the mechanism is simple enough to extend to whatever dynamic scheme you would like.
You can check this site for Multiple Tutorials & examples for UIScrollview. The link:
is Here..
I am sure, you'll able to find some good code for your need. Hope it works for you.

UIViews laid out in Interface Builder changes position during execution (UIViewContentMode)

I have some graphics that is already scaled and cut correctly for my project.
I choose to build the UI in IB and positioned everything correctly, under size and position I left it a "Frame" (instead of layout).
At runtime my graphics is moved and stretched according to which UIViewContentMode I set.
If I was doing this completely in code and set a frame and no UIViewContentMode, Cocoa would respect this and leave the graphics alone. However IB does things a bit different.
I think my problem is that I don't precisely understand what the different UIViewContentMode's does and I can't find the correct one to "turn off" the manipulation of the graphics at runtime.
Can someone give my a little help on this one:)
Thanks in regards.
If you don't set the value, the default is UIViewContentModeScaleToFill. If doing it in code and then calling setNeedsDisplay does it "scale to fill"? I think it depends on how you "do it in code" when the content mode is enforced - I assume IB is doing some extra stuff in the init to apply the content mode that you are not doing in code.
Anyway, if you don't want it to "scale" you can pick any of the UIViewContentMode operations that don't have the word "Scale" in the name. Review the UIViewContentMode enum for details on what each one does.

Cocoa: How to morph a drag image while dragging

In Interface Builder.app (and some other cocoa apps), image dragging has a very nice/sexy effect of morphing the drag image while you drag a draggable item out of its window.
For example in Interface Buildler.app:
Show the Library Palette (⇧⌘L, or Tools Menu -> Library)
Drag an item out of the Library palette
NOTE: as you drag the item out of the Library Palette window, it morphs from an image of the original list item to an image of the icon of the dragged item.
I have fully implemented drag and drop in my Application using the normal Cocoa NSDragSource/NSDragDestination facilities.
However, I can't find a hook for doing this image morph while dragging. I'm returning the initial drag image by overriding
-[NSView dragImage:at:offset:event:pasteboard:source:slideBack:]
But this is only called at the beginning of the drag.
How do you signal that you would like to replace the current drag image (ideally using the sexy morph effect).
You guys beat me to it. :-)
Yes, JLNDragEffectManager is open source (with attribution in your apps, please) and available on my blog. It should work fine as-is with no modification back to 10.5, but I'm not sure back any further. Others linked to it (and it's easily googleable), so to avoid self-congratulatory blog linking, I'll leave it at that.
Issues: One developer commented on (and submitted code to fix) the lack of dragging offset support. I've just not gotten around to posting the update. That's the only outstanding issue I'm aware of.
Improvements: I'd like to add multiple "zones" (say, one per document, so dragging from doc to doc keeps table rows looking like table rows, but anywhere outside doc windows turns them into a file icon a la HFS Promise Drag). Some day ...
Design: The post itself details the reasoning behind the design and the relatively simple morphing effect (cross-fade plus size are animated using basic NSAnimation, etc.). The code (the class as well as the demo app) is thoroughly blocked out and commented.
Won't link to my own post but would love the karma of upvotes for my effort. ;-)
UPDATE: Similar (but better-integrated) functionality is available as of 10.7. If you are targeting 10.7 or higher, it's best to use the new API. JLNDragEffectManager works fine on 10.7, so it can be used for earlier-targeted versions.
JNLDragEffectManager does exactly that. :)
The API does not support this well. Joshua Nozzi gives a method that looks reasonable in this weblog post.
IB's effect isn't that fancy. It's a crossfade and scale. Hold down shift to see it more clearly.
As of 10.7+ the current approach is to use the
enumerateDraggingItemsWithOptions:
forView:
classes:
searchOptions:
usingBlock:
API on NSDraggingInfo. The documentation is really poor but the ADC samples like MultiPhotoFrame or TableViewPlayground can give a good idea on how to use the new mechanism.