I'm having an issue with TextFields, whenever I tween the containers that they are inside of, the text will sorta jump and not scale very smoothly. Is there a solution to this problem? I have tried setting cacheAsBitmap, and that doesn't seem to have any effect. Thanks.
Wanted to add that I'm doing this in AIR, and the tweens are not linear, as in, not just an x tween, it is a tween that is affecting both x and y. I have a feeling it may be due to this.
Make sure they are anti-aliased for animation and not for readability. You can find the setting in the textfield properties. If using script, like TweenLite, you may also want to consider rounding the position on update.
Change the anti-alias option to "antialias for animation" instead of "antialias for readablility."
As people in other answers state, you can try to round the values the textfield is set to, to partly (sometimes totally) avoid such "jumps".
If you're using a tween engine, like TweenLite, eaze, anything like that, you can try to look for a method to round the position :
for example by using the RoundPropsPlugin in Tweenlite,
or using the Math.round(value) function in an onUpdate event coming from the tween itself.
Most of the time, good tweening engine will have either (or even both !) of these solutions possible (if not, maybe consider changing engine, TweenLite or eaze are the two bests in my opinion !)
Related
I've ran into a (hard to catch) issue using transitions between scenes in Cocos2d-x.
Basically I normally do a fade in-fade out like this:
Director::getInstance()->replaceScene(TransitionFade::create(0.5, scene, Color3B(0, 0, 0)));
It looks visually good and proper and all but I realized that it can be dangerous. If I have a button to go from Scene A to Scene B this way, the transition will run for 0.5 seconds as per the above implementation. When tapping ONCE and waiting, everything will be fine but if you tap very fast, it IS possible to have the event of the button called another time, even though the first transition call is already under way. This can, and I think in my case, lead to all sorts of strange and dangerous things. Especially for me who often use a protocol/delegate pattern for fetch data callbacks etc.
Want we want to do is to disable any UI (at least, possibly more?) on scene A as soon as the transition starts just to be sure that no other pushes are possible to the same or any other button, causing more transitions to be launched which could cause harmful things. Or there should be some kind of feature within cocos2d-x to always refuse transitions if one transition is already under way... To me that sounds like the most sane thing at first thought.
Is there anything I missed or are transitions in cocos2d-x really this dangerous? Anyone tackled this? Maybe a way to check if a transition is already under way would be one way for me to get around this problem without hacking around on cocos2d-x itself?
The virtual cocos2d::Node function onEnterTransitionDidFinish() could be used to unregister your callbacks for web requests etc.
Assuming you don't use the cocos2d-x event system for any app logic during a transition you might also consider disabling the EventDispatcher to block the propagation of touch events.
You could simply disable the button after it triggers.
Or you could be super lazy and create a Layer/TouchListener to intercept touch when a transition begins (onEnterTransitionDidStart()), and destroy it along with your scene :)
i have been looking into an effective way to simulate a camera in as3. everywhere i have read have basically told me the same thing; dont move the character, just move the stage around it.
ok, that works for simple things. but what happens when you want to zoom in? simply inflating objects doesnt work, because distances fluctuate and movement values suddenly arent to scale.
is there an effective way to work around this? vcams (virtual cameras) seem like an easy alternative, but from my research, i cant afford that memory
One easy solution is to just scale the entire instance of the game itself.
So, create an instance of the game's class, just like you normally would, and center it on the stage.
Then use scaleX and scaleY to make the instance of the game look bigger. The game will still behave like it should and you won't need to adjust the movement values or anything like that.
I am new to libGDX. I am trying to move a sprite from one point to another by changing the x and y of the rectangle. Can I do this gradually ?
I am currently using this to set new co-ordinates
batch.draw(bucketCyan, bucket.x, bucket.y);
What you're talking about is called interpolation, and there are a bunch of different ways to do it. You can either update the variables yourself using the approach noone commented with, or you can check out the Interpolation class: http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Interpolation.html
Google Universal Tween Engine. It's an easy to use interpolation "engine". It lets you modify or interpolate any values over time. It is easy to use and works well. It's worth spending some time to get familiar with.
Since I don't know english very well, I'm not able to find clear examples and/or tutorials for what I'm trying to do.
So the (maybe stupid) question is:
How can I strongly customize tweens using Starling framework and make my Sprites(or MovieClips) following a line, curve or create every other non-linear movement that doesn't exist in Transition Class?
I have no problem with Basic Starling animation. So it should be a good start point.
Thanks in advance for examples, resources or suggestions.
PS. I already visit the "Starling Wiki" page about custom Transitions but, as a Beginner(almost Intermediate) coder I wasn't able to completely understand it.
I know there are many online resources about AS3/Starling/Flash/Nape/Box2D but it's not easy for a non-english Beginner programmer to understand them.
You can simple move Starling's movieClip by set .x .y .rotation
Since now, I haven't heard of scripted transition to make predefined non linear movement. As you said, you can move object from one position to another, but it won't happen in a curved line.
What I've done in the past is to predefine the path of the movement, as I needed exactly the same weird path. I did a path tween in Flash, then used one simple function to loop through all frames (using gotoAndStop()) and getting x and y property of the object, storing them in an array. This was done when initializing. Later on I could start animation on all my weird paths whenever I wanted, using onUpdate method of tween, and passing positions from the array I've populated in the beginning.
This of course is good if you have very weird paths. If you want very little curves, you could try to do a mathematical equation. Tween classes have an update function, which will be called on each frame. So on each frame you could do some calculations and modify the parameters. For example if you tween x and y properties, you could use the update function to add a random number to those values. Of course this will make very uncontrolled movement, I'm just giving an example.
The best solution I could think of, speaking of complexity/result ratio - to use Greensock's TweenMax (look at the second example) - it has a built in bezier tweening. This means it could move from point A to point B within a bezier curve. I think this will be a good solution for your problem :)
I have an object in a Movieclip that I currently have a tween set up for. I set it up on the stage, not with actionscript.
I need to dynamically change the duration of this tween. I have not found reference to a way to do this.
I don't mind dynamically creating the tween if I need to, setting the initial duration in code, but I still have not found any reference to changing the duration dynamically.
Is this possible?
I'm just learning as3, so sorry if this is something that should be obvious.
I strongly suggest you to switch to TweenLite/TweenMax library, it's awesome, free, super-easy to use and it will change the way you work!
Have a look here, and here on the forum there's an explanation on how to change duration dynamically
Ideally you'd do it by programming the tween, there are many libraries out there that make it quite easy.
One of the ones I use frequently is eaze-tween, it has a timeline tween function, though I haven't used it, it is worth a try. eaze(target).to(duration, { frame:"label" });
Grant Skinner's gtween library also seems to be able to that using the GTweenTimeline Class.
The other thing you can do is modify the frame the animation is at at a varied rate, so to speed it up you'd go through it two frames at a time, so twice as fast. This way makes it limited to multiples of speed.
If you want to have more control there you'd need to have a longer tween, otherwise you might notice movement that is not very smooth. The way to do that would be to have a transition of a 100 frames, and use a tweening library, where the on update makes the value of the tween(which is a number between 0 and 1) and multiply it by the number of frames(100) and update the frame mc.gotoAndStop(int(val*100);. You can then assign various tweening functions and durations.
hope it helps