关键词随机飞入飞出效果

今天又有人问了,吧啦吧啦在网盘里找到了备份 整理一下

其实当时我也是网上找的,不过年代久远出处不详了,抱歉

图图图:

http://blog.csdn.net/onlyonecoder/article/details/8518148

布局文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <com.hnxiaohu.huamu.widget.KeywordsFlow
        android:id="@+id/keywordsflow_Layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/button1"
        android:layout_alignParentTop="true" >

    </com.hnxiaohu.huamu.widget.KeywordsFlow>

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:onClick="onClick"
        android:text="飞入" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_toRightOf="@+id/button1"
        android:onClick="onClick"
        android:text="飞出" />

</RelativeLayout>

使用示例

package com.hnxiaohu.huamu.ui;

import java.util.Random;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;

import com.hnxiaohu.huamu.R;
import com.hnxiaohu.huamu.widget.KeywordsFlow;

public class KeywordsFlowDemo extends Activity implements OnClickListener {
	public static final String[] keywords = { "国贸360", "人民路", "大石桥", "新通桥",
			"紫荆山", "医学院", "二七广场", "碧沙岗", "凯旋门", "居易国际", "百货大楼", "体育馆", "沙门村",
			"刘庄", "陈寨", "科技市场", "火车站" };
	public static final String[] keywords2 = { "火锅", "小吃", "咖啡", "电影院", "KTV",
			"茶馆", "足浴", "按摩", "超市", "银行", "酒店", "超市", "豫菜", "川菜", "蛋糕店", "医院",
			"面包店", "商场", "书店", "烧烤", "海鲜", "清真" };
	private KeywordsFlow keywordsFlow;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.keywordsflow);

		keywordsFlow = (KeywordsFlow) findViewById(R.id.keywordsflow_Layout);
		keywordsFlow.setDuration(800l);
		keywordsFlow.setOnClickListener(this);
	}
	// 填充关键词
	private void feedKeywordsFlow(KeywordsFlow keywordsFlow, String[] arr) {
		Random random = new Random();
		for (int i = 0; i < KeywordsFlow.MAX; i++) {
			int ran = random.nextInt(arr.length);
			String tmp = arr[ran];
			keywordsFlow.feedKeyword(tmp);
		}
	}

	@Override
	public void onClick(View v) {

		if(v.getId()==R.id.button1){
			keywordsFlow.rubKeywords();
			feedKeywordsFlow(keywordsFlow, keywords);
			keywordsFlow.go2Show(KeywordsFlow.ANIMATION_IN);
			return;
		}

		if(v.getId()==R.id.button2){
			keywordsFlow.rubKeywords();
			feedKeywordsFlow(keywordsFlow, keywords2);
			keywordsFlow.go2Show(KeywordsFlow.ANIMATION_OUT);
			return;
		}

		if(v instanceof TextView){
			String keyword = ((TextView) v).getText().toString();
			Toast.makeText(getApplication(), keyword, Toast.LENGTH_SHORT).show();
			return;
		}

	}

}

自定义View

package com.hnxiaohu.huamu.widget;

import java.util.LinkedList;
import java.util.Random;
import java.util.Vector;

import android.content.Context;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.FrameLayout;
import android.widget.TextView;

/**
 *关键词飞入和飞出动画效果
 */
public class KeywordsFlow extends FrameLayout implements OnGlobalLayoutListener {
	public static final int IDX_X = 0;
	public static final int IDX_Y = 1;
	public static final int IDX_TXT_LENGTH = 2;
	public static final int IDX_DIS_Y = 3;
	/** 由外至内的动画。 */
	public static final int ANIMATION_IN = 1;
	/** 由内至外的动画。 */
	public static final int ANIMATION_OUT = 2;
	/** 位移动画类型:从外围移动到坐标点。 */
	public static final int OUTSIDE_TO_LOCATION = 1;
	/** 位移动画类型:从坐标点移动到外围。 */
	public static final int LOCATION_TO_OUTSIDE = 2;
	/** 位移动画类型:从中心点移动到坐标点。 */
	public static final int CENTER_TO_LOCATION = 3;
	/** 位移动画类型:从坐标点移动到中心点。 */
	public static final int LOCATION_TO_CENTER = 4;
	public static final long ANIM_DURATION = 800l;
	public static final int MAX = 10;
	public static final int TEXT_SIZE_MAX = 25;
	public static final int TEXT_SIZE_MIN = 15;
	private OnClickListener itemClickListener;
	private static Interpolator interpolator;
	private static AlphaAnimation animAlpha2Opaque;
	private static AlphaAnimation animAlpha2Transparent;
	private static ScaleAnimation animScaleLarge2Normal, animScaleNormal2Large,
			animScaleZero2Normal, animScaleNormal2Zero;
	/** 存储显示的关键字。 */
	private Vector<String> vecKeywords;
	private int width, height;
	/**
	 * go2Show()中被赋值为true,标识开发人员触发其开始动画显示。<br/>
	 * 本标识的作用是防止在填充keywrods未完成的过程中获取到width和height后提前启动动画。<br/>
	 * 在show()方法中其被赋值为false。<br/>
	 * 真正能够动画显示的另一必要条件:width 和 height不为0。<br/>
	 */
	private boolean enableShow;
	private Random random;
	/**
	 * @see ANIMATION_IN
	 * @see ANIMATION_OUT
	 * @see OUTSIDE_TO_LOCATION
	 * @see LOCATION_TO_OUTSIDE
	 * @see LOCATION_TO_CENTER
	 * @see CENTER_TO_LOCATION
	 * */
	private int txtAnimInType, txtAnimOutType;
	/** 最近一次启动动画显示的时间。 */
	private long lastStartAnimationTime;
	/** 动画运行时间。 */
	private long animDuration;

	public KeywordsFlow(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		init();
	}

	public KeywordsFlow(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	public KeywordsFlow(Context context) {
		super(context);
		init();
	}

	private void init() {
		lastStartAnimationTime = 0l;
		animDuration = ANIM_DURATION;
		random = new Random();
		vecKeywords = new Vector<String>(MAX);
		getViewTreeObserver().addOnGlobalLayoutListener(this);
		interpolator = AnimationUtils.loadInterpolator(getContext(),
				android.R.anim.decelerate_interpolator);
		animAlpha2Opaque = new AlphaAnimation(0.0f, 1.0f);
		animAlpha2Transparent = new AlphaAnimation(1.0f, 0.0f);
		animScaleLarge2Normal = new ScaleAnimation(2, 1, 2, 1);
		animScaleNormal2Large = new ScaleAnimation(1, 2, 1, 2);
		animScaleZero2Normal = new ScaleAnimation(0, 1, 0, 1);
		animScaleNormal2Zero = new ScaleAnimation(1, 0, 1, 0);
	}

	public long getDuration() {
		return animDuration;
	}

	public void setDuration(long duration) {
		animDuration = duration;
	}

	public boolean feedKeyword(String keyword) {
		boolean result = false;
		if (vecKeywords.size() < MAX) {
			result = vecKeywords.add(keyword);
		}
		return result;
	}

	/**
	 * 开始动画显示。<br/>
	 * 之前已经存在的TextView将会显示退出动画。<br/>
	 *
	 * @return 正常显示动画返回true;反之为false。返回false原因如下:<br/>
	 *         1.时间上不允许,受lastStartAnimationTime的制约;<br/>
	 *         2.未获取到width和height的值。<br/>
	 */
	public boolean go2Show(int animType) {
		if (System.currentTimeMillis() - lastStartAnimationTime > animDuration) {
			enableShow = true;
			if (animType == ANIMATION_IN) {
				txtAnimInType = OUTSIDE_TO_LOCATION;
				txtAnimOutType = LOCATION_TO_CENTER;
			} else if (animType == ANIMATION_OUT) {
				txtAnimInType = CENTER_TO_LOCATION;
				txtAnimOutType = LOCATION_TO_OUTSIDE;
			}
			disapper();
			boolean result = show();
			return result;
		}
		return false;
	}

	private void disapper() {
		int size = getChildCount();
		for (int i = size - 1; i >= 0; i--) {
			final TextView txt = (TextView) getChildAt(i);
			if (txt.getVisibility() == View.GONE) {
				removeView(txt);
				continue;
			}
			FrameLayout.LayoutParams layParams = (LayoutParams) txt
					.getLayoutParams();
			// Log.d("ANDROID_LAB", txt.getText() + " leftM=" +
			// layParams.leftMargin + " topM=" + layParams.topMargin
			// + " width=" + txt.getWidth());
			int[] xy = new int[] { layParams.leftMargin, layParams.topMargin,
					txt.getWidth() };
			AnimationSet animSet = getAnimationSet(xy, (width >> 1),
					(height >> 1), txtAnimOutType);
			txt.startAnimation(animSet);
			animSet.setAnimationListener(new AnimationListener() {
				public void onAnimationStart(Animation animation) {
				}

				public void onAnimationRepeat(Animation animation) {
				}

				public void onAnimationEnd(Animation animation) {
					txt.setOnClickListener(null);
					txt.setClickable(false);
					txt.setVisibility(View.GONE);
				}
			});
		}
	}

	private boolean show() {
		if (width > 0 && height > 0 && vecKeywords != null
				&& vecKeywords.size() > 0 && enableShow) {
			enableShow = false;
			lastStartAnimationTime = System.currentTimeMillis();
			int xCenter = width >> 1, yCenter = height >> 1;
			int size = vecKeywords.size();
			int xItem = width / size, yItem = height / size;
			// Log.d("ANDROID_LAB", "--------------------------width=" + width +
			// " height=" + height + "  xItem=" + xItem
			// + " yItem=" + yItem + "---------------------------");
			LinkedList<Integer> listX = new LinkedList<Integer>(), listY = new LinkedList<Integer>();
			for (int i = 0; i < size; i++) {
				// 准备随机候选数,分别对应x/y轴位置
				listX.add(i * xItem);
				listY.add(i * yItem + (yItem >> 2));
			}
			// TextView[] txtArr = new TextView[size];
			LinkedList<TextView> listTxtTop = new LinkedList<TextView>();
			LinkedList<TextView> listTxtBottom = new LinkedList<TextView>();
			for (int i = 0; i < size; i++) {
				String keyword = vecKeywords.get(i);
				// 随机颜色
				int ranColor = 0xff000000 | random.nextInt(0x0077ffff);
				// 随机位置,糙值
				int xy[] = randomXY(random, listX, listY, xItem);
				// 随机字体大小
				int txtSize = TEXT_SIZE_MIN
						+ random.nextInt(TEXT_SIZE_MAX - TEXT_SIZE_MIN + 1);
				// 实例化TextView
				final TextView txt = new TextView(getContext());
				txt.setOnClickListener(itemClickListener);
				txt.setText(keyword);
				txt.setTextColor(ranColor);
				txt.setTextSize(TypedValue.COMPLEX_UNIT_SP, txtSize);
				txt.setShadowLayer(2, 2, 2, 0xff696969);
				txt.setGravity(Gravity.CENTER);
				// 获取文本长度
				Paint paint = txt.getPaint();
				int strWidth = (int) Math.ceil(paint.measureText(keyword));
				xy[IDX_TXT_LENGTH] = strWidth;
				// 第一次修正:修正x坐标
				if (xy[IDX_X] + strWidth > width - (xItem >> 1)) {
					int baseX = width - strWidth;
					// 减少文本右边缘一样的概率
					xy[IDX_X] = baseX - xItem + random.nextInt(xItem >> 1);
				} else if (xy[IDX_X] == 0) {
					// 减少文本左边缘一样的概率
					xy[IDX_X] = Math.max(random.nextInt(xItem), xItem / 3);
				}
				xy[IDX_DIS_Y] = Math.abs(xy[IDX_Y] - yCenter);
				txt.setTag(xy);
				if (xy[IDX_Y] > yCenter) {
					listTxtBottom.add(txt);
				} else {
					listTxtTop.add(txt);
				}
			}
			attach2Screen(listTxtTop, xCenter, yCenter, yItem);
			attach2Screen(listTxtBottom, xCenter, yCenter, yItem);
			return true;
		}
		return false;
	}

	/** 修正TextView的Y坐标将将其添加到容器上。 */
	private void attach2Screen(LinkedList<TextView> listTxt, int xCenter,
			int yCenter, int yItem) {
		int size = listTxt.size();
		sortXYList(listTxt, size);
		for (int i = 0; i < size; i++) {
			TextView txt = listTxt.get(i);
			int[] iXY = (int[]) txt.getTag();
			// Log.d("ANDROID_LAB", "fix[  " + txt.getText() + "  ] x:" +
			// iXY[IDX_X] + " y:" + iXY[IDX_Y] + " r2="
			// + iXY[IDX_DIS_Y]);
			// 第二次修正:修正y坐标
			int yDistance = iXY[IDX_Y] - yCenter;
			// 对于最靠近中心点的,其值不会大于yItem<br/>
			// 对于可以一路下降到中心点的,则该值也是其应调整的大小<br/>
			int yMove = Math.abs(yDistance);
			inner: for (int k = i - 1; k >= 0; k--) {
				int[] kXY = (int[]) listTxt.get(k).getTag();
				int startX = kXY[IDX_X];
				int endX = startX + kXY[IDX_TXT_LENGTH];
				// y轴以中心点为分隔线,在同一侧
				if (yDistance * (kXY[IDX_Y] - yCenter) > 0) {
					// Log.d("ANDROID_LAB", "compare:" +
					// listTxt.get(k).getText());
					if (isXMixed(startX, endX, iXY[IDX_X], iXY[IDX_X]
							+ iXY[IDX_TXT_LENGTH])) {
						int tmpMove = Math.abs(iXY[IDX_Y] - kXY[IDX_Y]);
						if (tmpMove > yItem) {
							yMove = tmpMove;
						} else if (yMove > 0) {
							// 取消默认值。
							yMove = 0;
						}
						// Log.d("ANDROID_LAB", "break");
						break inner;
					}
				}
			}
			// Log.d("ANDROID_LAB", txt.getText() + " yMove=" + yMove);
			if (yMove > yItem) {
				int maxMove = yMove - yItem;
				int randomMove = random.nextInt(maxMove);
				int realMove = Math.max(randomMove, maxMove >> 1) * yDistance
						/ Math.abs(yDistance);
				iXY[IDX_Y] = iXY[IDX_Y] - realMove;
				iXY[IDX_DIS_Y] = Math.abs(iXY[IDX_Y] - yCenter);
				// 已经调整过前i个需要再次排序
				sortXYList(listTxt, i + 1);
			}
			FrameLayout.LayoutParams layParams = new FrameLayout.LayoutParams(
					FrameLayout.LayoutParams.WRAP_CONTENT,
					FrameLayout.LayoutParams.WRAP_CONTENT);
			layParams.gravity = Gravity.LEFT | Gravity.TOP;
			layParams.leftMargin = iXY[IDX_X];
			layParams.topMargin = iXY[IDX_Y];
			addView(txt, layParams);
			// 动画
			AnimationSet animSet = getAnimationSet(iXY, xCenter, yCenter,
					txtAnimInType);
			txt.startAnimation(animSet);
		}
	}

	public AnimationSet getAnimationSet(int[] xy, int xCenter, int yCenter,
			int type) {
		AnimationSet animSet = new AnimationSet(true);
		animSet.setInterpolator(interpolator);
		if (type == OUTSIDE_TO_LOCATION) {
			animSet.addAnimation(animAlpha2Opaque);
			animSet.addAnimation(animScaleLarge2Normal);
			TranslateAnimation translate = new TranslateAnimation((xy[IDX_X]
					+ (xy[IDX_TXT_LENGTH] >> 1) - xCenter) << 1, 0,
					(xy[IDX_Y] - yCenter) << 1, 0);
			animSet.addAnimation(translate);
		} else if (type == LOCATION_TO_OUTSIDE) {
			animSet.addAnimation(animAlpha2Transparent);
			animSet.addAnimation(animScaleNormal2Large);
			TranslateAnimation translate = new TranslateAnimation(0, (xy[IDX_X]
					+ (xy[IDX_TXT_LENGTH] >> 1) - xCenter) << 1, 0,
					(xy[IDX_Y] - yCenter) << 1);
			animSet.addAnimation(translate);
		} else if (type == LOCATION_TO_CENTER) {
			animSet.addAnimation(animAlpha2Transparent);
			animSet.addAnimation(animScaleNormal2Zero);
			TranslateAnimation translate = new TranslateAnimation(0,
					(-xy[IDX_X] + xCenter), 0, (-xy[IDX_Y] + yCenter));
			animSet.addAnimation(translate);
		} else if (type == CENTER_TO_LOCATION) {
			animSet.addAnimation(animAlpha2Opaque);
			animSet.addAnimation(animScaleZero2Normal);
			TranslateAnimation translate = new TranslateAnimation(
					(-xy[IDX_X] + xCenter), 0, (-xy[IDX_Y] + yCenter), 0);
			animSet.addAnimation(translate);
		}
		animSet.setDuration(animDuration);
		return animSet;
	}

	/**
	 * 根据与中心点的距离由近到远进行冒泡排序。
	 *
	 * @param endIdx
	 *            起始位置。
	 * @param txtArr
	 *            待排序的数组。
	 *
	 */
	private void sortXYList(LinkedList<TextView> listTxt, int endIdx) {
		for (int i = 0; i < endIdx; i++) {
			for (int k = i + 1; k < endIdx; k++) {
				if (((int[]) listTxt.get(k).getTag())[IDX_DIS_Y] < ((int[]) listTxt
						.get(i).getTag())[IDX_DIS_Y]) {
					TextView iTmp = listTxt.get(i);
					TextView kTmp = listTxt.get(k);
					listTxt.set(i, kTmp);
					listTxt.set(k, iTmp);
				}
			}
		}
	}

	/** A线段与B线段所代表的直线在X轴映射上是否有交集。 */
	private boolean isXMixed(int startA, int endA, int startB, int endB) {
		boolean result = false;
		if (startB >= startA && startB <= endA) {
			result = true;
		} else if (endB >= startA && endB <= endA) {
			result = true;
		} else if (startA >= startB && startA <= endB) {
			result = true;
		} else if (endA >= startB && endA <= endB) {
			result = true;
		}
		return result;
	}

	private int[] randomXY(Random ran, LinkedList<Integer> listX,
			LinkedList<Integer> listY, int xItem) {
		int[] arr = new int[4];
		arr[IDX_X] = listX.remove(ran.nextInt(listX.size()));
		arr[IDX_Y] = listY.remove(ran.nextInt(listY.size()));
		return arr;
	}

	public void onGlobalLayout() {
		int tmpW = getWidth();
		int tmpH = getHeight();
		if (width != tmpW || height != tmpH) {
			width = tmpW;
			height = tmpH;
			show();
		}
	}

	public Vector<String> getKeywords() {
		return vecKeywords;
	}

	public void rubKeywords() {
		vecKeywords.clear();
	}

	/** 直接清除所有的TextView。在清除之前不会显示动画。 */
	public void rubAllViews() {
		removeAllViews();
	}

	public void setOnClickListener(OnClickListener listener) {
		itemClickListener = listener;
	}
}
时间: 2024-08-22 02:59:09

关键词随机飞入飞出效果的相关文章

CSS3实现Tooltip提示框飞入飞出动画

我们见过很多利用背景图片制作的Tooltip提示框,但是缺点是扩展比较麻烦,要经常改动图片.还有就是利用多层CSS的叠加实现,但是效果比较生硬,外观不怎么好看.今天我来分享一下利用CSS3快速实现既美观又实用的Tooltip提示框,提示框伴有飞入飞出的动画效果.先来看看效果图. 看上去还简单吧,其实实现的思路的确很简单. 具体效果我们可以在这里查看在线演示. 接下来我们来简单分析一下这个Tooltip实现的CSS3代码. 首先是HTML代码,主要是构造了3个小图标菜单以及对应的Tooltip提示

android自定义控件之飞入飞出控件

最近呢,本人辞职了,在找工作期间,不幸碰到了这个求职淡季,另外还是大学生毕业求职的高峰期,简历发了无数份却都石沉大海,宝宝心里那是一个苦啊!翻着过去的代码,本人偶然找到了一个有意思的控件,那时本人还没有写博客的习惯,现在补上,先看效果图: 然后看用法代码: StellarMap stellarMap = (StellarMap) findViewById(R.id.stellar); // 设置数据 RecommendAdapter adapter = new RecommendAdapter(

界面切换之飞入飞出

用QT实现的一个简单动画,比较简单 所以,直接上代码,呵呵. [cpp] view plaincopyprint? //tqt.h #ifndef TQT_H_ #define TQT_H_ #include <QtGui> #include <QtCore> class Widget : public QWidget { Q_OBJECT private: QFrame *frame[10]; QPushButton *prevButton; QPushButton *nextB

文字飞入和飞出

转载请注明出处:http://blog.csdn.net/forwardyzk/article/details/42493641 我们看到在一个界面上,文字可以从里向外飞出,也可以从外向里飞入,下面我们就研究一下这个效果. 思路: 1.设置要最新要展示的文字. 2.设置View的动画 (1)设置当前的View消失 如果是飞入,设置当前的View动画 渐变动画:由不透明变成透明 伸缩动画:缩小 平移动画:向里平移 如果是飞出 渐变动画:由不透明变成透明 伸缩动画:由放大 平移动画:向外平移 (2

分享20个华丽的模态窗口弹出效果示例(梦想天空)

分享20个华丽的模态窗口弹出效果示例 在你的品牌和网站访问者之间建立情感联系是非常重要的.模态弹出窗口可能会帮助您完成这个具有挑战性的任务,以及分享给游客一些重要信息.作为一项常用规则,模态弹出窗口被用于各种号召行动的消息,如鼓励用户订阅新闻邮件,下载一些免费赠品或通知关于一些新的产品,服务或功能发布等.在这里,你会看到值得你注意的20个华丽的弹出窗口示例. 您可能感兴趣的相关文章 经典网页设计:超炫动画效果单页网站 30个独具匠心的精美单页网站设计案例 25个以全屏照片为背景的精美网页作品 2

一个随机上翻的小效果

html <!DOCTYPE html> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="Content-Type" content="text/html; charset=uft-8"> <meta name="keywords

Android PopupWindow 仿微信弹出效果

项目中,我需要PopupWindow的时候特别多,这个东西也特别的好使,所以我今天给大家写一款PopupWindow 仿微信弹出效果,这样大家直接拿到项目里就可以用了!首先让我们先看效果: 那么我首先先看下布局代码非常简单:如下 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/pop_layout" android:layout_

飞页效果,可以制作页码更换

这个效果使用了自己封装的一个运动函数:这个效果的巧妙之处在于,在开始用数组存放了每个li的位置信息,然后在点击按钮(页码)的时候让li的宽高位置和透明度发生运动的改变一个一个的消失,然后在消失结束之后,再一个个倒着出现:可以和页码进行匹配,从而实现页码更换的效果 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title><

cocos2d-x 弹入、弹出效果(以菜单为例子)

弹入和弹出菜单为了使动作更平滑,涉及到动作组合.(CCMoveTo .CCEaseExponentialOut)(菜单背景图位置仅为示范例子,还需调整) 以菜单的背景图为例: //生成菜单背景图 CCSprite* MainMenuBG = CCSprite::create("menu_bg.png"); MainMenuBG->setPosition(ccp(visibleSize.width/2 +10,visibleSize.height +20)); this->a