public override bool OnFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (Math.Abs(velocityX) < 500) { return(false); } _lastView = _parentActivity.LastView; var animationSet = new AnimationSet(true) { Interpolator = new AccelerateDecelerateInterpolator(), Duration = 300, FillAfter = true }; var animationRotate = new RotateAnimation(0, Math.Sign(velocityX) * 15); var animationTranslate = new TranslateAnimation(0, Math.Sign(velocityX) * 400, 0, 10); var animationAlpha = new AlphaAnimation(1, 0); animationSet.AddAnimation(animationRotate); animationSet.AddAnimation(animationTranslate); animationSet.AddAnimation(animationAlpha); animationSet.AnimationEnd += AnimationSet_AnimationEnd; _lastView.StartAnimation(animationSet); return(true); }
public override void initView() { btn_start = FindViewById <Button> (Resource.Id.btn_start); tv_maintitle = FindViewById <TextView> (Resource.Id.tv_maintitle); ll_root = FindViewById <LinearLayout> (Resource.Id.ll_root); //ll_root animation AnimationSet set = new AnimationSet(true); //rotate animation RotateAnimation rotate = new RotateAnimation(0, 360, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f); //scale animation ScaleAnimation scaleAnimation = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f); set.AddAnimation(rotate); set.AddAnimation(scaleAnimation); set.Duration = 2000; set.FillAfter = true; ll_root.StartAnimation(set); set.AnimationEnd += delegate(object sender, Animation.AnimationEndEventArgs e) { handler.PostDelayed(delegate() { NineOldAndroids.View.ViewPropertyAnimator.Animate(tv_maintitle).SetDuration(1200).Alpha(1.0f).Start(); }, 2000); handler.PostDelayed(delegate() { btn_start.Visibility = ViewStates.Visible; NineOldAndroids.View.ViewPropertyAnimator.Animate(btn_start).SetDuration(1500).TranslationY(-150).Start(); }, 1200); }; }
public static AnimationSet getInAnimation(Context context) { AnimationSet _in = new AnimationSet(context, null); AlphaAnimation alpha = new AlphaAnimation(0.0f, 1.0f); alpha.Duration = 90; ScaleAnimation scale1 = new ScaleAnimation(0.8f, 1.05f, 0.8f, 1.05f, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f); scale1.Duration = 135; ScaleAnimation scale2 = new ScaleAnimation(1.05f, 0.95f, 1.05f, 0.95f, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f); scale2.Duration = 105; scale2.StartOffset = 135; ScaleAnimation scale3 = new ScaleAnimation(0.95f, 1f, 0.95f, 1.0f, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f); scale3.Duration = 60; scale3.StartOffset = 240; _in.AddAnimation(alpha); _in.AddAnimation(scale1); _in.AddAnimation(scale2); _in.AddAnimation(scale3); return(_in); }
public void ShowInvalid(string errorMessage) { nextMustBeDeleted = true; textErrorView.Text = errorMessage; AddView(textErrorView); textErrorView.Visibility = ViewStates.Visible; AnimationSet animationSet = new AnimationSet(true); AlphaAnimation fadeIn = new AlphaAnimation(0, 1); fadeIn.Duration = 300; AlphaAnimation fadeOut = new AlphaAnimation(1, 0); fadeOut.StartOffset = 300 + 300; fadeOut.Duration = 300; animationSet.AddAnimation(fadeIn); animationSet.AddAnimation(fadeOut); animationSet.FillAfter = true; animationSet.FillBefore = true; animationSet.AnimationEnd += (sender, args) => { textErrorView.Visibility = ViewStates.Gone; RemoveView(textErrorView); }; textErrorView.StartAnimation(animationSet); }
private void animateAlphaTranslate(View view, float alphaFrom, float alphaTo, float xFrom, float xTo, bool requestFocus) { AnimationSet animationSet = new AnimationSet(true); AlphaAnimation fade = new AlphaAnimation(alphaFrom, alphaTo); fade.Duration = 350; TranslateAnimation slide = new TranslateAnimation(Dimension.RelativeToSelf, xFrom, Dimension.RelativeToSelf, xTo, Dimension.RelativeToSelf, 0, Dimension.RelativeToSelf, 0); slide.Duration = 350; animationSet.AddAnimation(fade); animationSet.AddAnimation(slide); view.StartAnimation(animationSet); if (requestFocus) { animationSet.AnimationEnd += (obj, args) => view.RequestFocus(); } }
public static LayoutAnimationController getListAnimTranslate() { try { AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.Duration = 500;//(500); set.AddAnimation(animation); animation = new TranslateAnimation(Dimension.RelativeToSelf, 0.0f, Dimension.RelativeToSelf, 0.0f, Dimension.RelativeToSelf, -1.0f, Dimension.RelativeToSelf, 0.0f); animation.Duration = 800; //(800); set.AddAnimation(animation); LayoutAnimationController controller = new LayoutAnimationController( set, 0.5f); controller.Order = DelayOrder.Random; return(controller); } catch (Exception) { return(null); } }
public void StartSecondaryCircleAnimation() { int bottomMovementAddition = (260 * parentWidth) / 700; TranslateAnimation translateAnimation = new TranslateAnimation(GetX(), GetX(), GetY(), GetY() + bottomMovementAddition) { StartOffset = 200, Duration = 1000 }; AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0) { StartOffset = 1300, Duration = 200 }; AnimationSet animationSet = new AnimationSet(true) { FillAfter = true }; animationSet.AddAnimation(translateAnimation); animationSet.AddAnimation(alphaAnimation); animationSet.AnimationEnd += (s, e) => { SetState(AnimationState.SecondaryCircleFinished); }; StartAnimation(animationSet); }
private static Animation createShrinkAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta, long startOffset, long duration, IInterpolator interpolator) { AnimationSet animationSet = new AnimationSet(false); animationSet.FillAfter = true; long preDuration = duration / 2; Animation rotateAnimation = new RotateAnimation(0, 360, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f); rotateAnimation.StartOffset = startOffset; rotateAnimation.Duration = preDuration; rotateAnimation.Interpolator = new LinearInterpolator(); rotateAnimation.FillAfter = true; animationSet.AddAnimation(rotateAnimation); Animation translateAnimation = new RotateAndTranslateAnimation(0, toXDelta, 0, toYDelta, 360, 720); translateAnimation.StartOffset = startOffset + preDuration; translateAnimation.Duration = duration - preDuration; translateAnimation.Interpolator = interpolator; translateAnimation.FillAfter = true; animationSet.AddAnimation(translateAnimation); return(animationSet); }
public static Animation createItemInAnimation(Context context, int index, long expandDuration, int x, int y) { RotateAnimation rotate = new RotateAnimation(720, 0, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f); rotate.SetInterpolator(context, Resource.Animation.sat_item_in_rotate_interpolator); rotate.Duration = expandDuration; TranslateAnimation translate = new TranslateAnimation(x, 0, y, 0); long delay = 250; if (expandDuration <= 250) { delay = expandDuration / 3; } long duration = 400; if ((expandDuration - delay) > duration) { duration = expandDuration - delay; } translate.Duration = duration; translate.StartOffset = delay; translate.SetInterpolator(context, Resource.Animation.sat_item_anticipate_interpolator); AlphaAnimation alphaAnimation = new AlphaAnimation(1f, 0f); long alphaDuration = 10; if (expandDuration < 10) { alphaDuration = expandDuration / 10; } alphaAnimation.Duration = alphaDuration; alphaAnimation.StartOffset = (delay + duration) - alphaDuration; AnimationSet animationSet = new AnimationSet(false); animationSet.FillAfter = false; animationSet.FillBefore = true; animationSet.FillEnabled = true; animationSet.AddAnimation(alphaAnimation); animationSet.AddAnimation(rotate); animationSet.AddAnimation(translate); animationSet.StartOffset = 30 * index; animationSet.Start(); animationSet.StartNow(); return(animationSet); }
/// <summary> /// Explodes the specified view. /// </summary> /// <param name="view">The view.</param> /// <param name="duration">The duration of the explosion.</param> /// <param name="onHidden">The callback that is invoked when the view is no longer visible.</param> public void Explode(View view, long duration, Action onHidden) { const float vibrateAmount = 0.05f; var preDuration = (long)(duration * 0.25f); var explosionDuration = (long)(duration * 0.75f); var startDelay = (long)(duration * 0.15f); // get the bounds var r = new Rect(); view.GetGlobalVisibleRect(r); var location = new int[2]; GetLocationOnScreen(location); r.Offset(-location[0], -location[1]); r.Inset(-ExpansionLimit, -ExpansionLimit); var set = new AnimationSet(true); // vibrate var vibrate = new VibrateAnimation(view.Width * vibrateAmount, view.Height * vibrateAmount); vibrate.Duration = preDuration; set.AddAnimation(vibrate); // implode var alpha = new AlphaAnimation(1.0f, 0.0f); alpha.Duration = preDuration; alpha.StartOffset = startDelay; set.AddAnimation(alpha); var scale = new ScaleAnimation( 1.0f, 0.0f, 1.0f, 0.0f, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f); scale.Duration = preDuration; scale.StartOffset = startDelay; set.AddAnimation(scale); // apply on complete set.AnimationEnd += delegate { view.Visibility = ViewStates.Invisible; if (onHidden != null) { onHidden(); } }; view.StartAnimation(set); // explode Explode(Utils.CreateBitmapFromView(view), r, startDelay, explosionDuration); }
public static AnimationSet getOutAnimation(Context context) { AnimationSet _out = new AnimationSet(context, null); AlphaAnimation alpha = new AlphaAnimation(1.0f, 0.0f); alpha.Duration = 150; ScaleAnimation scale = new ScaleAnimation(1.0f, 0.6f, 1.0f, 0.6f, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f); scale.Duration = 150; _out.AddAnimation(alpha); _out.AddAnimation(scale); return(_out); }
private static Animation CreateItemDisapperAnimation(long duration, bool isClicked) { AnimationSet animationSet = new AnimationSet(true); animationSet.AddAnimation(new ScaleAnimation(1.0f, isClicked ? 2.0f : 0.0f, 1.0f, isClicked ? 2.0f : 0.0f, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f)); animationSet.AddAnimation(new AlphaAnimation(1.0f, 0.0f)); animationSet.Duration = duration; animationSet.Interpolator = new DecelerateInterpolator(); animationSet.FillAfter = true; return(animationSet); }
protected Animation CreateExitAnimation() { var exitAnimSet = new AnimationSet(true); exitAnimSet.AddAnimation(new AlphaAnimation(0, 1) { Duration = 400 }); exitAnimSet.AddAnimation(new Rotate3dAnimation(0, 100, 0, 50, 50) { Duration = 400 }); return(exitAnimSet); }
/// <summary> /// Handles the Elapsed event of the autoShowTimer control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="ElapsedEventArgs"/> instance containing the event data.</param> private void autoShowTimer_Elapsed(object sender, ElapsedEventArgs e) { lock (this) { if (autoShowTimer != null) { autoShowTimer.Dispose(); autoShowTimer = null; imageView.Post(() => { lock (this) { if (IsRunning && imageView.Animation == null) { // // Start an animation for rotating the spinner forever. // var anim = new RotateAnimation(0, 360f, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f) { Duration = 1500, RepeatCount = Animation.Infinite, Interpolator = new LinearInterpolator() }; var animationSet = new AnimationSet(false); animationSet.AddAnimation(anim); imageView.StartAnimation(animationSet); imageView.Visibility = ViewStates.Visible; } } }); } } }
public static void NoConnection() { var context = ViewHelper.CurrentActivity(); context.RunOnUiThread(delegate { var NoConnection = context.FindViewById(Resource.Id.NoConnection); if (NoConnection != null) { NoConnection.Visibility = ViewStates.Visible; new Handler().PostDelayed(delegate { Android.Views.Animations.Animation fadeOut = new AlphaAnimation(1, 0); fadeOut.Interpolator = new DecelerateInterpolator(); fadeOut.Duration = 1000; AnimationSet animation = new AnimationSet(false); animation.AddAnimation(fadeOut); NoConnection.Animation = animation; NoConnection.StartAnimation(animation); new Handler().PostDelayed(delegate { NoConnection.Visibility = ViewStates.Gone; }, 1000); }, 2000); } }); }
/** * Fades the view in, delays the specified amount of time, then fades the view out * @param v the view to be faded in then out * @param delay how long the view will be visible for */ public static void FadeInThenOut(View v, long delay) { if (v == null) { return; } v.Visibility = ViewStates.Visible; AnimationSet animation = new AnimationSet(true); Animation[] fadeInOut = FadeInThenOutAnimation(500, delay); animation.AddAnimation(fadeInOut[0]); animation.AddAnimation(fadeInOut[1]); animation.AnimationEnd += (sender, args) => v.Visibility = ViewStates.Gone; animation.AnimationStart += (sender, args) => v.Visibility = ViewStates.Visible; }
/** * The {@code FlipDirection} enumeration defines the most typical flip view transitions: left-to-right and right-to-left. {@code FlipDirection} is used during the creation of {@link FlipAnimation} animations. * * @author Ephraim A. Tekle * */ /** * Create a pair of {@link FlipAnimation} that can be used to flip 3D transition from {@code fromView} to {@code toView}. A typical use case is with {@link ViewAnimator} as an out and in transition. * * NOTE: Avoid using this method. Instead, use {@link #flipTransition}. * * @param fromView the view transition away from * @param toView the view transition to * @param dir the flip direction * @param duration the transition duration in milliseconds * @param interpolator the interpolator to use (pass {@code null} to use the {@link AccelerateInterpolator} interpolator) * @return */ public static Animation[] FlipAnimation(View fromView, View toView, FlipDirection dir, long duration, IInterpolator interpolator) { Animation[] result = new Animation[2]; float centerX; float centerY; centerX = fromView.Width / 2.0f; centerY = fromView.Height / 2.0f; FlipAnimation outFlip = new FlipAnimation(0, dir.EndDegreeForFirstView(), centerX, centerY, SpotTiles.FlipAnimation.ScaleDefault, ScaleUpDownEnum.ScaleDown); outFlip.Duration = duration; outFlip.FillAfter = true; outFlip.Interpolator = interpolator ?? new AccelerateInterpolator(); if (dir == FlipDirection.BottomTop || dir == FlipDirection.TopBottom) { outFlip.Direction = Direction.X; } else { outFlip.Direction = Direction.Y; } AnimationSet outAnimation = new AnimationSet(true); outAnimation.AddAnimation(outFlip); result[0] = outAnimation; // Uncomment the following if toView has its layout established (not the case if using ViewFlipper and on first show) //centerX = toView.getWidth() / 2.0f; //centerY = toView.getHeight() / 2.0f; FlipAnimation inFlip = new FlipAnimation(dir.StartDegreeForSecondView(), 0, centerX, centerY, SpotTiles.FlipAnimation.ScaleDefault, ScaleUpDownEnum.ScaleUp); inFlip.Duration = duration; inFlip.FillAfter = true; inFlip.StartOffset = duration; inFlip.Interpolator = interpolator ?? new AccelerateInterpolator(); if (dir == FlipDirection.BottomTop || dir == FlipDirection.TopBottom) { outFlip.Direction = Direction.X; } else { outFlip.Direction = Direction.Y; } AnimationSet inAnimation = new AnimationSet(true); inAnimation.AddAnimation(inFlip); result[1] = inAnimation; return(result); }
private void fadeBart(object sender, System.EventArgs e) { AnimationSet animationSet = new AnimationSet(false); long duration = 300; animationSet.AddAnimation(createAnimation(1f, 0.5f, 1f, 0.5f, duration, 0)); animationSet.AddAnimation(createAnimation(1f, 4f, 1f, 4f, duration, 1 * duration)); animationSet.AddAnimation(createAnimation(1f, 0.5f, 1f, 0.5f, duration, 2 * duration)); animationSet.FillAfter = true; // scale(0.5f,1000,0); //scale(2f,1000,1000); //scale(1f,1000,2000); _imageViewBart.StartAnimation(animationSet); }
private Animation CreatePositionAnimation(int fromY, int toY, float fromAlpha, float toAlpha, int duration) { TranslateAnimation translate = new TranslateAnimation(0, 0, fromY, toY); translate.Duration = duration; AlphaAnimation alpha = new AlphaAnimation(fromAlpha, toAlpha); alpha.Duration = duration; AnimationSet set = new AnimationSet(true); //i can't resolve under line //set.SetInterpolator(new ITimeInterpolator()); set.AddAnimation(translate); set.AddAnimation(alpha); return(set); }
public static Animation CreateItemOutAnimation(Context context, int index, long expandDuration, int x, int y) { var alphaAnimation = new AlphaAnimation(0.0f, 1f); long num1 = 60; if (expandDuration < 60L) { num1 = expandDuration / 4L; } alphaAnimation.Duration = num1; alphaAnimation.StartOffset = 0L; var translateAnimation = new TranslateAnimation(0.0f, x, 0.0f, y) { StartOffset = 0L, Duration = expandDuration }; translateAnimation.SetInterpolator(context, Resource.Animation.popoutMenuItemOvershootInterpolator); var rotateAnimation = new RotateAnimation(0.0f, 360f, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f); rotateAnimation.SetInterpolator(context, Resource.Animation.popoutMenuItemOutRotateInterpolator); long num2 = 100; if (expandDuration <= 150L) { num2 = expandDuration / 3L; } rotateAnimation.Duration = expandDuration - num2; rotateAnimation.StartOffset = num2; var animationSet = new AnimationSet(false) { FillAfter = false, FillBefore = true, FillEnabled = true }; animationSet.AddAnimation(alphaAnimation); animationSet.AddAnimation(rotateAnimation); animationSet.AddAnimation(translateAnimation); animationSet.StartOffset = 30 * index; return(animationSet); }
private void MaximizeView(View view) { var animationSet = new AnimationSet(true) { Interpolator = new AccelerateDecelerateInterpolator(), Duration = 500, FillAfter = true }; var scaleAnimation = new ScaleAnimation(1f, 1.25f, 1f, 1.25f, Dimension.RelativeToSelf, 0f, Dimension.RelativeToSelf, 0f); _selectedViewTop = view.Top; _selectedViewLeft = view.Left; var translateAnimation = new TranslateAnimation(Dimension.RelativeToSelf, 0, Dimension.Absolute, -view.Left, Dimension.RelativeToSelf, 0, Dimension.Absolute, -view.Top + _addButton.Height); animationSet.AddAnimation(scaleAnimation); animationSet.AddAnimation(translateAnimation); view.StartAnimation(animationSet); }
public static Animation CreateItemInAnimation(Context context, int index, long expandDuration, int x, int y) { var translateAnimation = new TranslateAnimation(x, 0.0f, y, 0.0f); long num1 = 250; if (expandDuration <= 250L) { num1 = expandDuration / 3L; } long num2 = 250; if (expandDuration - num1 > num2) { num2 = expandDuration - num1; } translateAnimation.Duration = num2; translateAnimation.StartOffset = num1; var alphaAnimation = new AlphaAnimation(1f, 0.0f); long num3 = 10; if (expandDuration < 10L) { num3 = expandDuration / 10L; } alphaAnimation.Duration = num3; alphaAnimation.StartOffset = num1 + num2 - num3; var animationSet = new AnimationSet(false) { FillAfter = false, FillBefore = true, FillEnabled = true }; animationSet.AddAnimation(alphaAnimation); animationSet.AddAnimation(translateAnimation); animationSet.StartOffset = 30 * index; animationSet.Start(); animationSet.StartNow(); return(animationSet); }
public static Animation createItemOutAnimation(Context context, int index, long expandDuration, int x, int y) { AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f); long alphaDuration = 60; if (expandDuration < 60) { alphaDuration = expandDuration / 4; } alphaAnimation.Duration = alphaDuration; alphaAnimation.StartOffset = 0; TranslateAnimation translate = new TranslateAnimation(0, x, 0, y); translate.StartOffset = 0; translate.Duration = expandDuration; translate.SetInterpolator(context, Resource.Animation.sat_item_overshoot_interpolator); RotateAnimation rotate = new RotateAnimation(0f, 360f, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f); rotate.SetInterpolator(context, Resource.Animation.sat_item_out_rotate_interpolator); long duration = 100; if (expandDuration <= 150) { duration = expandDuration / 3; } rotate.Duration = expandDuration - duration; rotate.StartOffset = duration; AnimationSet animationSet = new AnimationSet(false); animationSet.FillAfter = false; animationSet.FillBefore = true; animationSet.FillEnabled = true; //animationSet.addAnimation(alphaAnimation); //animationSet.addAnimation(rotate); animationSet.AddAnimation(translate); animationSet.StartOffset = 30 * index; return(animationSet); }
void UpdateTemperature() { var rotation = (IsImperial ? 2 : 1) * Temperature; var animSet = new AnimationSet(true); animSet.FillAfter = true; animSet.FillEnabled = true; var animRotate = new RotateAnimation(angle, rotation.GetValueOrDefault(0), Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f); animRotate.Duration = 400; animRotate.FillAfter = true; animSet.AddAnimation(animRotate); _needleImage.StartAnimation(animSet); angle = rotation.GetValueOrDefault(0); }
private AnimationSet InternalLoadAnimationSet(IniFile ini, string fileId) { AnimationSet animationSet = null; string img = ini.ReadString("", "image"); if (!string.IsNullOrEmpty(img)) { Texture tex = engine.GetTexture(img); if (tex != null) { animationSet = new AnimationSet(fileId, tex); int renderSizeX = 0; int renderSizeY = 0; int renderOffsetX = 0; int renderOffsetY = 0; int[] renderSize = ini.ReadString("", "render_size").ToIntValues(); if (renderSize.Length >= 2) { renderSizeX = renderSize[0]; renderSizeY = renderSize[1]; } int[] offsetSize = ini.ReadString("", "render_offset").ToIntValues(); if (offsetSize.Length >= 2) { renderOffsetX = offsetSize[0]; renderOffsetY = offsetSize[1]; } BlendMode blendMode = (BlendMode)ini.ReadInt("", "blend_mode"); byte alphaMod = (byte)ini.ReadInt("", "alpha_mod", 255); Color colorMod = new Color(255, 255, 255); string colorModStr = ini.ReadString("", "color_mod"); if (!string.IsNullOrEmpty(colorModStr)) { colorMod = colorModStr.ToColor(); } foreach (var sec in ini.Sections) { if (!string.IsNullOrEmpty(sec.Name)) { AnimationType type = sec.ReadString("type").ToAnimationType(); Animation anim = animationSet.AddAnimation(sec.Name, type, blendMode, alphaMod, colorMod); int frames = sec.ReadInt("frames"); int duration = sec.ReadString("duration").ToDuration(engine.MaxFramesPerSecond); int position = sec.ReadInt("position"); bool firstFrame = true; bool noFrame = true; foreach (var key in sec.KeyList) { if (key.Ident.Equals("frame")) { if (firstFrame) { anim.Setup(frames, duration); firstFrame = false; } noFrame = false; int[] values = key.Value.ToIntValues(); int index = values[0]; int direction = values[1]; int x = values[2]; int y = values[3]; int w = values[4]; int h = values[5]; int ox = values[6]; int oy = values[7]; anim.AddFrame(index, direction, x, y, w, h, ox, oy); } } if (noFrame && renderSizeX > 0 && renderSizeY > 0) { anim.Setup(frames, duration); anim.SetUncompressed(renderSizeX, renderSizeY, renderOffsetX, renderOffsetY, position, frames, duration); } } } } } return(animationSet); }
public override void Load() { //texture = GameManager.Instance.Content.Load<Texture2D>("Mario"); //animation = new Animation("Mario", 2, 50f); animations = new AnimationSet(); animations.AddAnimation("Left", "Player/Player_Still_Left", 2, 250, true); animations.AddAnimation("Right", "Player/Player_Still_Right", 2, 250, true); animations.AddAnimation("Jump_Left", "Player/Mario_Jump_Left", 1, 100, false); animations.AddAnimation("Jump_Right", "Player/Mario_Jump_Right", 1, 100, false); animations.AddAnimation("Death", "Player/Player_Death", 1, 100, false); animations.AddAnimation("Turn_Left", "Player/Player_Turn_Left", 1, 100, false); animations.AddAnimation("Turn_Right", "Player/Player_Turn_Right", 1, 100, false); animations.AddAnimation("Walk_Left", "Player/Player_Walk_Left", 4, 175, true); animations.AddAnimation("Walk_Right", "Player/Player_Walk_Right", 4, 175, true); animations.AddAnimation("Run_Left", "Player/Player_Run_Left", 4, 50, true); animations.AddAnimation("Run_Right", "Player/Player_Run_Right", 4, 50, true); animations.AddAnimation("RunJump_Left", "Player/Mario_RunJump_Left", 1, 100, false); animations.AddAnimation("RunJump_Right", "Player/Mario_RunJump_Right", 1, 100, false); currentAnimation = animations.GetAnimation("Left"); action = ""; debugtexture = GameManager.Instance.CreateColorTexture(20, 255, 20, 1); this.Width = 32; this.Height = 36; }
public override View GetView(int position, View convertView, ViewGroup parent) { if (convertView == null) { viewHolder = new NoticeViewHolder(); convertView = LayoutInflater.FromContext(context).Inflate(Resource.Layout.NoticeList, null); viewHolder.Title = convertView.FindViewById <TextView>(Resource.Id.lstTxtTitle); viewHolder.Description = convertView.FindViewById <TextView>(Resource.Id.lstTxtDescription); viewHolder.Icon = convertView.FindViewById <TextView>(Resource.Id.lstTxtExt); viewHolder.BaseCover = convertView.FindViewById <LinearLayout>(Resource.Id.listCover); viewHolder.BaseIcon = convertView.FindViewById <LinearLayout>(Resource.Id.lstIcon); Functions.SetElevation(6f, 12f, viewHolder.BaseIcon, viewHolder.BaseCover); viewHolder.Title.Typeface = Typeface.CreateFromAsset(context.Assets, "Fonts/OpenSans/OpenSans-Semibold.ttf"); viewHolder.Description.Typeface = Typeface.CreateFromAsset(context.Assets, "Fonts/OpenSans/OpenSans-Regular.ttf"); viewHolder.Icon.Typeface = Typeface.CreateFromAsset(context.Assets, "Fonts/OpenSans/OpenSans-Semibold.ttf"); Functions.ResizeText(viewHolder.Title, context); Functions.ResizeText(viewHolder.Description, context); Functions.ResizeText(viewHolder.Icon, context); viewHolder.BaseIcon.BackgroundTintList = ColorStateList.ValueOf(Color.ParseColor("#FF4040")); convertView.Tag = viewHolder; } else { viewHolder = convertView.Tag as NoticeViewHolder; } if (ShowCategory == QPCategories.Semester) { SetSemester(viewHolder, position); } else if (ShowCategory == QPCategories.Year) { SetYear(viewHolder, position); } else if (ShowCategory == QPCategories.QuestionPaper) { SetFile(viewHolder, position); } viewHolder.Icon.Text = "PDF"; Animation iconAnimation = AnimationUtils.LoadAnimation(context, Resource.Animation.SlideInRight); iconAnimation.Duration = 500; iconAnimation.Interpolator = new DecelerateInterpolator(1.2f); Animation contentAnimation = AnimationUtils.LoadAnimation(context, Resource.Animation.SlideInLeft); contentAnimation.Duration = 500; contentAnimation.Interpolator = new DecelerateInterpolator(1.2f); AnimationSet set = new AnimationSet(false); set.AddAnimation(iconAnimation); set.AddAnimation(contentAnimation); convertView.FindViewById <LinearLayout>(Resource.Id.lstIcon).Animation = iconAnimation; convertView.FindViewById <LinearLayout>(Resource.Id.listCover).Animation = contentAnimation; convertView.StartAnimation(set); return(convertView); }
public override View GetView(int position, View convertView, ViewGroup parent) { if (convertView == null) { viewHolder = new NoticeViewHolder(); convertView = LayoutInflater.FromContext(context).Inflate(Resource.Layout.NoticeList, null); viewHolder.Title = convertView.FindViewById <TextView>(Resource.Id.lstTxtTitle); viewHolder.Description = convertView.FindViewById <TextView>(Resource.Id.lstTxtDescription); viewHolder.Icon = convertView.FindViewById <TextView>(Resource.Id.lstTxtExt); viewHolder.BaseCover = convertView.FindViewById <LinearLayout>(Resource.Id.listCover); viewHolder.BaseIcon = convertView.FindViewById <LinearLayout>(Resource.Id.lstIcon); Functions.SetElevation(6f, 12f, viewHolder.BaseIcon, viewHolder.BaseCover); viewHolder.Title.Typeface = Typeface.CreateFromAsset(context.Assets, "Fonts/OpenSans/OpenSans-Semibold.ttf"); viewHolder.Description.Typeface = Typeface.CreateFromAsset(context.Assets, "Fonts/OpenSans/OpenSans-Regular.ttf"); viewHolder.Icon.Typeface = Typeface.CreateFromAsset(context.Assets, "Fonts/OpenSans/OpenSans-Semibold.ttf"); Functions.ResizeText(viewHolder.Title, context); Functions.ResizeText(viewHolder.Description, context); Functions.ResizeText(viewHolder.Icon, context); if (offlineFiles[position].FileExtension.ToUpper().Contains("PDF")) { viewHolder.BaseIcon.BackgroundTintList = ColorStateList.ValueOf(Color.ParseColor("#FF4040")); } else { viewHolder.BaseIcon.BackgroundTintList = ColorStateList.ValueOf(Color.ParseColor("#FF840E")); } convertView.Tag = viewHolder; } else { viewHolder = (NoticeViewHolder)convertView.Tag; } viewHolder.Title.Text = " " + System.IO.Path.GetFileNameWithoutExtension(offlineFiles[position].FilePath); viewHolder.Description.Text = "Category : " + category; viewHolder.Icon.Text = offlineFiles[position].FileExtension.Replace(".", "").ToUpper(); Animation iconAnimation = AnimationUtils.LoadAnimation(context, Resource.Animation.SlideInRight); iconAnimation.Duration = 500; iconAnimation.Interpolator = new DecelerateInterpolator(1.2f); Animation contentAnimation = AnimationUtils.LoadAnimation(context, Resource.Animation.SlideInLeft); contentAnimation.Duration = 500; contentAnimation.Interpolator = new DecelerateInterpolator(1.2f); AnimationSet set = new AnimationSet(false); set.AddAnimation(iconAnimation); set.AddAnimation(contentAnimation); convertView.FindViewById <LinearLayout>(Resource.Id.lstIcon).Animation = iconAnimation; convertView.FindViewById <LinearLayout>(Resource.Id.listCover).Animation = contentAnimation; convertView.StartAnimation(set); return(convertView); }
/// <summary> /// The workhorse of the animation processor. It loops through all /// animations, all tracks, and all keyframes, and converts to the format /// expected by the runtime animation classes. /// </summary> /// <param name="input">The NodeContent to process. Comes from the base ModelProcessor.</param> /// <param name="output">The ModelContent that was produced. You don't typically change this.</param> /// <param name="context">The build context (logger, etc).</param> /// <returns>An allocated AnimationSet with the animations to include.</returns> public virtual AnimationSet BuildAnimationSet(NodeContent input, ref ModelContent output, ContentProcessorContext context) { AnimationSet ret = new AnimationSet(); if (!DoAnimations) { context.Logger.LogImportantMessage("DoAnimation is set to false for {0}; not generating animations.", input.Name); return(ret); } // go from name to index Dictionary <string, ModelBoneContent> nameToIndex = new Dictionary <string, ModelBoneContent>(); foreach (ModelBoneContent mbc in output.Bones) { nameToIndex.Add(GetBoneName(mbc), mbc); } AnimationContentDictionary adict = MergeAnimatedBones(input); if (adict == null || adict.Count == 0) { context.Logger.LogWarning("http://kwxport.sourceforge.net/", input.Identity, "Model processed with AnimationProcessor has no animations."); return(ret); } foreach (AnimationContent ac in adict.Values) { if (!IncludeAnimation(ac)) { context.Logger.LogImportantMessage(String.Format("Not including animation named {0}.", ac.Name)); continue; } context.Logger.LogImportantMessage( "Processing animation {0} duration {1} sample rate {2} reduction tolerance {3}.", ac.Name, ac.Duration, SampleRate, Tolerance); AnimationChannelDictionary acdict = ac.Channels; AnimationTrackDictionary tracks = new AnimationTrackDictionary(); foreach (string name in acdict.Keys) { if (!IncludeTrack(ac, name)) { context.Logger.LogImportantMessage(String.Format("Not including track named {0}.", name)); continue; } int ix = 0; AnimationChannel achan = acdict[name]; int bix = nameToIndex[name].Index; context.Logger.LogMessage("Processing bone {0}:{1}.", name, bix); AnimationTrack at; if (tracks.TryGetValue(bix, out at)) { throw new System.ArgumentException( String.Format("Bone index {0} is used by multiple animations in the same clip (name {1}).", bix, name)); } // Sample at given frame rate from 0 .. Duration List <Keyframe> kfl = new List <Keyframe>(); int nFrames = (int)Math.Floor(ac.Duration.TotalSeconds * SampleRate + 0.5); for (int i = 0; i < nFrames; ++i) { Keyframe k = SampleChannel(achan, i / SampleRate, ref ix); kfl.Add(k); } // Run keyframe elimitation Keyframe[] frames = kfl.ToArray(); int nReduced = 0; if (tolerance_ > 0) { nReduced = ReduceKeyframes(frames, tolerance_); } if (nReduced > 0) { context.Logger.LogMessage("Reduced '{2}' from {0} to {1} frames.", frames.Length, frames.Length - nReduced, name); } // Create an AnimationTrack at = new AnimationTrack(bix, frames); tracks.Add(bix, at); } Animation a = new Animation(ac.Name, tracks, SampleRate); ret.AddAnimation(a); } // build the special "identity" and "bind pose" animations AnimationTrackDictionary atd_id = new AnimationTrackDictionary(); AnimationTrackDictionary atd_bind = new AnimationTrackDictionary(); foreach (KeyValuePair <string, ModelBoneContent> nip in nameToIndex) { Keyframe[] frames_id = new Keyframe[2]; frames_id[0] = new Keyframe(); frames_id[1] = new Keyframe(); AnimationTrack at_id = new AnimationTrack(nip.Value.Index, frames_id); atd_id.Add(nip.Value.Index, at_id); Keyframe[] frames_bind = new Keyframe[2]; Matrix mat = nip.Value.Transform; frames_bind[0] = Keyframe.CreateFromMatrix(mat); frames_bind[1] = new Keyframe(); frames_bind[1].CopyFrom(frames_bind[0]); AnimationTrack at_bind = new AnimationTrack(nip.Value.Index, frames_bind); atd_bind.Add(nip.Value.Index, at_bind); } ret.AddAnimation(new Animation("$id$", atd_id, 1.0f)); ret.AddAnimation(new Animation("$bind$", atd_bind, 1.0f)); return(ret); }
public override View GetView(int position, View convertView, ViewGroup parent) { string pubDate = notices[position].PublishDate.Split(new string[] { " +" }, StringSplitOptions.None)[0]; if (convertView == null) { viewHolder = new NoticeViewHolder(); convertView = LayoutInflater.FromContext(context).Inflate(Resource.Layout.NoticeList, null); viewHolder.Title = convertView.FindViewById <TextView>(Resource.Id.lstTxtTitle); viewHolder.Description = convertView.FindViewById <TextView>(Resource.Id.lstTxtDescription); viewHolder.Icon = convertView.FindViewById <TextView>(Resource.Id.lstTxtExt); viewHolder.BaseCover = convertView.FindViewById <LinearLayout>(Resource.Id.listCover); viewHolder.BaseIcon = convertView.FindViewById <LinearLayout>(Resource.Id.lstIcon); Functions.SetElevation(6f, 12f, viewHolder.BaseIcon, viewHolder.BaseCover); viewHolder.Title.Typeface = Typeface.CreateFromAsset(context.Assets, "Fonts/OpenSans/OpenSans-Semibold.ttf"); viewHolder.Description.Typeface = Typeface.CreateFromAsset(context.Assets, "Fonts/OpenSans/OpenSans-Regular.ttf"); viewHolder.Icon.Typeface = Typeface.CreateFromAsset(context.Assets, "Fonts/OpenSans/OpenSans-Semibold.ttf"); Functions.ResizeText(viewHolder.Title, context); Functions.ResizeText(viewHolder.Description, context); Functions.ResizeText(viewHolder.Icon, context); if (notices[position].HasImage) { viewHolder.BaseIcon.BackgroundTintList = ColorStateList.ValueOf(Color.ParseColor("#FF840E")); } else { viewHolder.BaseIcon.BackgroundTintList = ColorStateList.ValueOf(Color.ParseColor("#FF4040")); } convertView.Tag = viewHolder; } else { viewHolder = (NoticeViewHolder)convertView.Tag; } viewHolder.Title.Text = " " + notices[position].Title; viewHolder.Description.Text = pubDate; viewHolder.Icon.Text = notices[position].Extension; Animation iconAnimation = AnimationUtils.LoadAnimation(context, Resource.Animation.SlideInRight); iconAnimation.Duration = 500; iconAnimation.Interpolator = new DecelerateInterpolator(1.2f); Animation contentAnimation = AnimationUtils.LoadAnimation(context, Resource.Animation.SlideInLeft); contentAnimation.Duration = 500; contentAnimation.Interpolator = new DecelerateInterpolator(1.2f); AnimationSet set = new AnimationSet(false); set.AddAnimation(iconAnimation); set.AddAnimation(contentAnimation); convertView.FindViewById <LinearLayout>(Resource.Id.lstIcon).Animation = iconAnimation; convertView.FindViewById <LinearLayout>(Resource.Id.listCover).Animation = contentAnimation; convertView.StartAnimation(set); return(convertView); }
/// <summary> /// The workhorse of the animation processor. It loops through all /// animations, all tracks, and all keyframes, and converts to the format /// expected by the runtime animation classes. /// </summary> /// <param name="input">The NodeContent to process. Comes from the base ModelProcessor.</param> /// <param name="output">The ModelContent that was produced. You don't typically change this.</param> /// <param name="context">The build context (logger, etc).</param> /// <returns>An allocated AnimationSet with the animations to include.</returns> public virtual AnimationSet BuildAnimationSet(NodeContent input, ref ModelContent output, ContentProcessorContext context) { AnimationSet ret = new AnimationSet(); if (!DoAnimations) { context.Logger.LogImportantMessage("DoAnimation is set to false for {0}; not generating animations.", input.Name); return ret; } // go from name to index Dictionary<string, ModelBoneContent> nameToIndex = new Dictionary<string, ModelBoneContent>(); foreach (ModelBoneContent mbc in output.Bones) nameToIndex.Add(GetBoneName(mbc), mbc); AnimationContentDictionary adict = MergeAnimatedBones(input); if (adict == null || adict.Count == 0) { context.Logger.LogWarning("http://kwxport.sourceforge.net/", input.Identity, "Model processed with AnimationProcessor has no animations."); return ret; } foreach (AnimationContent ac in adict.Values) { if (!IncludeAnimation(ac)) { context.Logger.LogImportantMessage(String.Format("Not including animation named {0}.", ac.Name)); continue; } context.Logger.LogImportantMessage( "Processing animation {0} duration {1} sample rate {2} reduction tolerance {3}.", ac.Name, ac.Duration, SampleRate, Tolerance); AnimationChannelDictionary acdict = ac.Channels; AnimationTrackDictionary tracks = new AnimationTrackDictionary(); TimeSpan longestUniqueDuration = new TimeSpan(0); foreach (string name in acdict.Keys) { if (!IncludeTrack(name)) { context.Logger.LogImportantMessage(String.Format("Not including track named {0}.", name)); continue; } int ix = 0; AnimationChannel achan = acdict[name]; int bix = nameToIndex[name].Index; context.Logger.LogMessage("Processing bone {0}:{1}.", name, bix); AnimationTrack at; if (tracks.TryGetValue(bix, out at)) { throw new System.ArgumentException( String.Format("Bone index {0} is used by multiple animations in the same clip (name {1}).", bix, name)); } // Sample at given frame rate from 0 .. Duration List<Keyframe> kfl = new List<Keyframe>(); int nFrames = (int)Math.Floor(ac.Duration.TotalSeconds * SampleRate + 0.5); for (int i = 0; i < nFrames; ++i) { Keyframe k = SampleChannel(achan, i / SampleRate, ref ix); kfl.Add(k); } // Run keyframe elimitation Keyframe[] frames = kfl.ToArray(); int nReduced = 0; if (tolerance_ > 0) nReduced = ReduceKeyframes(frames, tolerance_); if (nReduced > 0) context.Logger.LogMessage("Reduced '{2}' from {0} to {1} frames.", frames.Length, frames.Length - nReduced, name); // Create an AnimationTrack at = new AnimationTrack(bix, frames); Debug.Assert(name != null); at.Name = name; tracks.Add(bix, at); } if (ShouldTrimAnimation(ac)) { TrimAnimationTracks(ac.Name, tracks, context); } Animation a = new Animation(ac.Name, tracks, SampleRate); ret.AddAnimation(a); } // build the special "identity" and "bind pose" animations AnimationTrackDictionary atd_id = new AnimationTrackDictionary(); AnimationTrackDictionary atd_bind = new AnimationTrackDictionary(); foreach (KeyValuePair<string, ModelBoneContent> nip in nameToIndex) { if (!IncludeTrack(nip.Key)) continue; Keyframe[] frames_id = new Keyframe[2]; frames_id[0] = new Keyframe(); frames_id[1] = new Keyframe(); AnimationTrack at_id = new AnimationTrack(nip.Value.Index, frames_id); at_id.Name = nip.Key; atd_id.Add(nip.Value.Index, at_id); Keyframe[] frames_bind = new Keyframe[2]; Matrix mat = nip.Value.Transform; frames_bind[0] = Keyframe.CreateFromMatrix(mat); frames_bind[1] = new Keyframe(); frames_bind[1].CopyFrom(frames_bind[0]); AnimationTrack at_bind = new AnimationTrack(nip.Value.Index, frames_bind); at_bind.Name = nip.Key; atd_bind.Add(nip.Value.Index, at_bind); } ret.AddAnimation(new Animation("$id$", atd_id, 1.0f)); ret.AddAnimation(new Animation("$bind$", atd_bind, 1.0f)); return ret; }