zoukankan      html  css  js  c++  java
  • 用Easing函数实现碰撞效果

    用Easing函数实现碰撞效果

    工程中需要的源码请从这里下载:

    https://github.com/YouXianMing/EasingAnimation

    源码:

    //
    //  ViewController.m
    //  EasingView
    //
    //  Created by YouXianMing on 15/1/17.
    //  Copyright (c) 2015年 YouXianMing. All rights reserved.
    //
    
    #import "ViewController.h"
    #import "YXEasing.h"
    
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        // 显示的view
        UIView *showView            = [[UIView alloc] initWithFrame:CGRectMake(100, -100, 100, 100)];
        showView.backgroundColor    = [UIColor clearColor];
        showView.layer.borderColor  = [UIColor redColor].CGColor;
        showView.layer.borderWidth  = 4.f;
        showView.layer.cornerRadius = 50.f;
        [self.view addSubview:showView];
        
        // 关键帧动画
        CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
        
        // 设置值
        [animation setValues:[YXEasing calculateFrameFromPoint:showView.center
                                                       toPoint:CGPointMake(showView.center.x, showView.center.y + 565)
                                                          func:BounceEaseOut
                                                    frameCount:100]];
        
        // 设置持续时间
        animation.duration  = 1.f;
        
        // 执行动画效果
        showView.center = CGPointMake(showView.center.x, showView.center.y + 565);
        [showView.layer addAnimation:animation forKey:nil];
    }
    
    @end
  • 相关阅读:
    设置CentOS7 静态获取IP
    视图与索引
    常用sql语句--DQL
    数据完整性
    常用sql语句--DML
    常用数据类型
    常用sql语句--DDL
    命令提示符内简单操作MySQL
    cnpm安装教程
    js生成指定范围的随机整数
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/4231077.html
Copyright © 2011-2022 走看看