Loading in background - createjs

All game assests are broken into portions according to the game Levels.
So while user play Level #1, next level is being loaded in background.
But there is a strange behaviour with the sprites when preloading is active.
Sprites are played way faster.
Here is a test case: http://cjstest.comlu.com/index.html
Click "Play" button. You can see a moving rect at 16 FPS speed.
Click "Load L2" button. You'll notice that rect has started moving faster.

Look this tutorial
Use event.delta for the animation not depent of framerate.
function tick(event) {
// move 100 pixels per second (elapsedTimeInMS / 1000msPerSecond * pixelsPerSecond):
circle.x += event.delta/1000*100;
}

Related

CreateJS MovieClip performance issue

I'm using Adobe Animate HTML5 to create a board game to run on Smart TV (low-performance machine).
All my previous games were done using AS3.
I quickly found there is no way to create a Sprite anymore (A movie clips with only 1 frame).
After creating my board game (no code yet just elements) which is basically movie clips inside other movie clips. All single frame.
I checked the FPS on LG TV and so it is done from 60 to 20. On a static image.
After research, I found that is the advance method in MovieClip class there is a constant check to update the frame.
I added a change to check if the MovieClip class total frame is equal to 1 to change it the mode of the MovieClip to a single frame. This increases performance back to 60 FPS.
Who do I go to, to check and maybe fix/"add a feature" to the code of createjs
Thanks
code issues or suggestions can be logged here https://github.com/CreateJS/EaselJS/issues for CreateJS. All the best.
inside html-code in script part there is a line
createjs.Ticker.addEventListener("tick", stage);
Remove it and call the update manually when you need it (when something has changed)
stage.update();

How to stop MPAndroidChart chart.centerViewToAnimated( currentXVisible + 60, currentY, YAxis.AxisDependency.LEFT, 15000 );

I am wanting to animate my drawn data, with controls much like a media player: Play, Stop, fast forward, etc....over my Xaxis - AKA over time....
I have tried creating my own Runnable both on and off the UI thread with no success with making calls to increment the xvalue by small amounts, etc .... but does not move the view port windows.
I can get my chart to animate using chart.centerViewToAnimated, but want to be able to "stop" this animation ... I cannot see how to do this even with a ViewPortHandler...
Any ideas??
It looks like the animation started by chart.centerViewToAnimated(...) cannot be cancelled. So you need to make small steps. If the steps are small enough, you can use chart.centerViewTo(...) (without animation).
I have implemented this with 50ms interval and it looks decent.

No keyframes are visible but the object still moves

I'm using Blender 2.8 and I just have 2 objects: hand and gun and I want to create animations for them. So, for instance, I want to create a simple firing animation. What I do:
1. I create animation for gun
2. I create animation for hand
But if I switch somehow incorrectly I "lose" the first animation I've created. I tried creating fake users and stuff. I just don't get why I select the armature for which I've just created the animation, it plays, but there are no keyframes.
Here's the vid, here's the file.
Ask me questions if you have any.
The movement may be cached in Blender, you may need to reset the movement cache.
Alternatively, you should look at both the Track Controller and Dopesheet(action editor) - the animation may be stored in both.
The movement could be related to parenting ( to an object that is moving )
The movement could also be caused by physics simulation of a rigid body.
Hopefully with the help of the above, you find the problem.
I had the same problem. In the Animation mode (horizontal tabs across the top of the window), click on the object to animate.
The keyframes will appear.
If the object is not selected, the keyframes disappear.
Just leaving this here so that nobody spends 30 minutes trying to work this out, like i just did.

UIView animateWithDuration: slows down animation frame rate

I am using CADisplayLink to draw frames using the EAGLView method in a game at 60 times per second.
When I call UIView animateWithDuration: the framerate drops down to exactly half, from 60 to 30 fps for the duration of the animation. Once the animation is over, the fps rises instantly back up to 60.
I also tried using NSTimer animation method instead of CADisplayLink and still get the same result.
The same behavior happens when I press the volume buttons while the speaker icon is fading out, so it may be using animateWithDuration. As I would like to be able to handle the speaker icon smoothly in my app, this means I can't just rewrite my animation code to use a different method other than animateWithDuration, but need to find a solution that works with it.
I am aware that there is an option to slow down animations for debug on the simulator, however, I am experiencing this on the device and no such option is enabled. I also tried using various options for animateWithDuration such as the linear one and the user interaction, but none had an improvement.
I am also aware I can design an engine that can still work with a frame rate that varies widely. However, this is not an ideal solution to this problem, as high fps is desirable for games.
Has someone seen this problem or solved it before?
The solution to this is to do your own animation and blit during the CADisplayLink callback.
1) for the volume issue, put a small volume icon in the corner, or show it if the user takes some predefined touch action, and give them touch controls. With that input you can use AVAudioPlayer to vary the volume, and just avoid the system control altogether. you might even be able to determine the user has pressed the volume buttons, and pop some note saying do it your way. This gets you away from any animations happening by the system.
2) When you have an animation you want to do, well, create a series of images in code (either then or before hand), and every so many callbacks in the displayLink blit the image to the screen.
Here's an old thread that describes similar drops in frame rate. In that case, the cause of the problem was adding two or more semi-transparent sprites, but I'd guess that any time you try to composite several layers together you may be doing enough work to cut the frame rate, and animateWithDuration very likely does exactly that kind of thing.
Either use OpenGL or CoreAnimation. They are not compatible.
To test this remove any UIView animation, the frame rate will be what you expect. Add back UIView animation, it will drop to 30fps.
You said:
When I call UIView animateWithDuration: the framerate drops down to exactly half, from 60 to 30 fps for the duration of the animation. Once the animation is over, the fps rises instantly back up to 60
I dont know why your not accepting my answer, this is exactly what happens when you combine UIView animation with CA animation not using a UIView.

draw with opengl less than every frame

Is their any way, in cocos2d, to have a cclayer draw via opengl less frequently than every frame? I have tried:
-(void) draw
{
glEnable(GL_LINE_SMOOTH);
if (iShouldUpdate) {
ccDrawLine(ccp(50,50), ccp(200,200));
iShouldUpdate = false;
}
}
-(void) updateTheMap
{
iShouldUpdate = true;
}
and then call: updateTheMap whenever needed, but it just displays for 1 frame.
Thanks.
Yes and no.
Normally the frame contents are cleared before a new frame renders. Every frame begins at a clean state. Now if you were to disable clearing of the screen, you could draw something once and it would stay on screen. But then you wouldn't be able to move what you've drawn without clearing exactly just the parts that you've drawn.
Since this gets overly complex and error prone really quickly, the standard way for games has been ever since there are game engines to clear the frame contents before beginning to draw a new frame. One notable exception being DooM, where it was assumed by the engine developer that every pixel on screen would be updated every frame - unless there were missing textures in which case you could see the famous Halls of Mirrors (HOM) effect that occurs when you're not clearing the framebuffer every frame:
So the standard is to draw the entire screen contents again every frame. Because of that, you can't draw something just every couple of frames because if you do that, then whatever you've drawn will be visible on screen for one frame and then it'll be gone.
In summation: you have to draw everything that should be visible on screen repeatedly every frame. That's the way almost all game engines work.