android - Cocos2D Android中在sprite外画框产生选择效果

标签 android cocos2d-android

我有一个 View 可以一次包含多个 Sprite ,现在我想在我触摸一个 Sprite 时有一个选择效果。 一些有用/帮助链接会非常有帮助。

最佳答案

我看到两种方式:

  1. 更改所选版本的 sprite(使原始 sprite 不可见并显示所选版本)。

  2. 创建一个帧 Sprite (可能来自多个部分(将它们添加到一个父级))并在您需要选择原始 Sprite 时显示它。

一些代码

CCNode *base = [CCNode node];
CCSprite *original = [CCSprite node]; //change this to create your sprite
[base addChild:original]

CCNode *frameNode = [CCNode node];
[base addChild: frameNode];
[frameNode setVisible:NO];
CCSprite *part1 = [CCSprite node]; //replace to create your part
[frameNode addChild: part1];
[part1 setAnchorPoint:. ...];
[part1 setPosition: ...];
[part1 setRotation: ...];
//add more parts

当您的原始 Sprite 被选中时:

[frameNode setVisible: YES]; //you can also use some CCAction to make it appear more beautiful

关于android - Cocos2D Android中在sprite外画框产生选择效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7724307/

相关文章:

android - 安装 gradle 以在 cordova build android 中使用

android - 我应该使用cocos2D还是andengine?

android - Cocos2D android背景图片搞砸了

android - 在启动您的应用程序时关闭设备音乐

android.permission.SET_TIME_ZONE 状态 "Not for use by third-party applications"

android - 带 Assets 的 Cordova 插件

Android:您必须先在 child 的 parent 身上调用 removeView() 2

java - android中已弃用类的现有等价物

java - 为什么我会收到 InvocationTargetException?安卓2D游戏

android - 表面 View 作为 android 中的位图