CreateJS play a child movieclip - movieclip

If you have a child movieclip on stage with an animation in it, can you have the main timeline play the child movieclip at a certain timeline?
mc_child is a 20 frame animation with this.stop() at frame one so that it is paused at the beginning.
If you add the code this.mc_child.play() or this.mc_child.gotoAndPlay(5) you get an error in createJS. "Uncaught TypeError: Cannot read property 'play' of undefined."
How do you make child movieclips play at a certain frame?

You can use gotoAndPlay(5);
Have a look at the EaselJS documentation:
http://www.createjs.com/docs/easeljs/classes/MovieClip.html

Related

Metal drawable drops ALL frames when the window is occluded by other windows

I have an app that displays a brief animation in a CAMetalLayer.
When my app's window is fully or at least partially visible, the animation is rendered fully and properly.
However, once the app's window gets fully occluded by another window, the animation stops rendering at some point, and when I switch back to my app's window I find it showing an intermediate frame of the animation.
I've added a presentation completion handler to each current drawable with - [id<MTLDrawable> addPresentedHandler:] and it does get called, however the - [id<MTLDrawable> presentedTime] starts giving 0 continuously on all frames after the window gets occluded. The docs say:
MTLDrawable
presentedTime
The host time, in seconds, when the drawable was displayed onscreen.
The property value is 0.0 if the drawable hasn’t been presented or if
its associated frame was dropped.
So it looks like when the window is occluded, ALL frames get dropped. Why does this happen? Is there a way to work around this?

How to terminate a SCNTransaction ongoing?

I use SCNTransaction to move game objects. More specifically, when the player taps somewhere on the screen, the object will move towards that destination. But sometimes the player may make a wrong move, so I want to create a button which can terminate all SCNTransactions.
However, unlike SKAction, which can be terminated with a simple line - self.removeAllActions(), SCNTransaction cannot be terminated or even paused from the outside according to the Apple Developer Documentation. Even worse, I find that before the object reaches its destination, its position has already changed to the destination's position, so I cannot simply use another SCNTransaction to counteract the ongoing one after knowing the object's current position.
Can anybody give me some hints? Thanks a lot.
SCNTransaction and its animation principles follow the one of Core Animation and CATransaction. To stop an animation you will have to set the model value to the current presentation value. For instance:
node.position = node.presentation.position
But if you are familiar with SKAction and would like to implement the same logic in your SceneKit app, you might want to have a look at SCNAction. They work identically.

How to specify SCNAction to use scene time base

I'm trying to control playback of a scene by using SCNRenderer render(atTime:viewport:commandBuffer:passDescriptor:) method, according to Apple document:
By default, the playback timing of actions and animations in a scene
is based on the system time, not the scene time. Before using this
method to control the playback of animations, set the
uses​Scene​Time​Base property of each animation to YES, or specify the
SCNScene​Source​Animation​Import​Policy​Play​Using​Scene​Time​Base
option when loading a scene file that contains animations.
I can only specify the property uses​Scene​Time​Base of CoreAnimation animation. Is SCNAction have any property to change playback to scene time?

Scenekit orientation in IOS

I have imported a Collada file into my scene and I am using allowsCameraControl to rotate / pan the object / pan the object
I now need functionality to jump instantly to the front or side view of the object.
Does anybody know how I can get the camera that Scenekit implements in my scene and how to rotate this camera to show the front and back view ?
"Front view" and "side view" are notions that are defined in terms of your content, so you have to define them yourself.
Create a node (let's call it "frontViewNode" for example) with an attached SCNCamera and position/orient it so that it's looking at whatever you call the "front" of your object. See this answer if you need help with that.
Create another node ("sideViewNode") that's looking at whatever you call the "side" of your object.
When you want to switch views, set the pointOfView property on the SCNView displaying your scene to either your "frontViewNode" or your "sideViewNode". You can even do this inside an animation (see SCNTransaction) to make the camera view swoop around between the two viewpoints.

Flash play() processed immediately?

Does the play() function in Flash:
move the playhead of the MovieClip to the next frame -- as soon as play() is called
change the MovieClip's state to "playing" -- actually move MovieClip to next frame, when movie moves to next frame
In normal circumstances it would be option 2. However, it is possible to have the frame re-drawn immediately. There is a catch though, you can only do this within mouse move and timer interval handlers. In AS3 have a look at the MouseEvent.updateAfterEvent and the TimerEvent.updateAfterEvent methods. In AS 2 there is a global updateAfterEvent function you can call with the same restrictions.
I think its 2. change the MovieClip's state to "playing"

Resources