1.通过find方式获取
//获取节点
var node=cc.find("Canvas/logo");
//获取精灵组件
var sprite=node.getComponent(cc.Sprite); 2.通过在构造函数中定义组件,并且从层级管理器中拉入节点。
cc.Class({
extends: cc.Component,
properties: {
label: {
default: null,
type: cc.Label
},
logo: {
default: null,
type: cc.Sprite
},
}
//代码中访问组件
self.logo.spriteFrame = new cc.SpriteFrame(img);

Cocos Creator 获取节点的方式的更多相关文章

  1. Cocos Creator 获取当前URL取参数

    利用Javascript获取当前页的URL,这个问题起来好像很复杂,如果第一次去想这个问题,很多人估计又在琢磨到底又是哪个神一般的Javascript函数. 其实不是,Javascript获取当前页的 ...

  2. Cocos Creator 获取当前 Pageview 翻页到第几页的事件索引

    新建一个js,叫做 pageAction写一个方法 pageViewClick:function(event,coustom){ var node = event.node; this.pageInd ...

  3. JS(基础)_总结获取页面中元素和节点的方式

    一.前言 1.元素和节点的区别 2.总结获取元素的方式 3.总结获取节点的方式 二.主要内容 1.结点和元素的区别 (1)一些常见基本概念: 文档:document 元素:页面中所有的标签 结点:页面 ...

  4. Cocos Creator 中 _worldMatrix 到底是什么(中)

    Cocos Creator 中 _worldMatrix 到底是什么(中) 1. 中篇摘要 在上篇中主要做了三件事 简单表述了矩阵的基本知识,以及需要涉及到的三角函数知识 推导了图形变换中 位移 .旋 ...

  5. <3>Cocos Creator编辑器基础

    Cocos Creator编辑器界面主要窗口包含如下: * 资源管理器窗口 * 场景编辑器窗口 * 层级管理器窗口 * 属性检查器窗口 * 上方功能按钮 * 偏好设置 * 串口输出 * 预览和构建 1 ...

  6. Cocos Creator学习笔记

    1.动态加载图片 cc.Class({ extends: cc.Component, properties: { label: { default: null, type: cc.Label }, l ...

  7. Cocos Creator学习目录

    目录 安装和启动 文件结构 编辑器基础 基本概念 (场景树 节点 坐标 组件 ) Cocos Creator 脚本简介 Cocos Creator调试 节点 cc.Node 组件开发cc.Compon ...

  8. <7>Cocos Creator 节点 cc.Node

    1.简介 节点(cc.Node)是渲染的必要组成部分.所有需要在游戏场景中显示的内容都必须是节点或者依附于节点之上.节点负责控制显示内容的位置.大小.旋转.缩放.颜色等信息. 2.节点属性 1: na ...

  9. Cocos Creator学习二:查找节点和查找组件

    1.目的:只有通过方便的获取节点对象以及组件,才能较好的进行逻辑控制. 2.通过 cc.find(节点全路径名称字符串) 获取节点. 3.通过getComponent获取组件(注意一个是类型,一个是类 ...

随机推荐

  1. 排查 docker flow proxy 的 503 问题

    这是今天我们在开发环境下 docker swarm 集群上遇到的问题,在这篇博文中记录一下排查过程. 先登录到应用容器内检查一下其中运行的站点是否能正常访问: # docker exec -it 02 ...

  2. 一篇采访窥C#的未来

    今天坐公交时用手机打开 .NET Blog 阅读这周的 The week in .NET ,在看 Virtual Panel: What's Next for .NET? 这篇采访报道时,被其中对 R ...

  3. 为什么实数系里不存在最小正数?(Why the smallest positive real number doesn't exist in the real number system ?)

    We define the smallest positive real number as the number which is explicitly greater than zero and ...

  4. Hive日志(Hive Logging)--hive GettingStarted翻译

    Hive uses log4j for logging. By default logs are not emitted to the console by the CLI. The default ...

  5. 2017年蓝桥杯省赛A组c++第5题(递归算法填空)

    /* 由 A,B,C 这3个字母就可以组成许多串. 比如:"A","AB","ABC","ABA","AACB ...

  6. Cmake入门资料

    1.http://blog.sina.com.cn/s/blog_3f3422fd010009vn.html 2.http://www.cnblogs.com/coderfenghc/tag/cmak ...

  7. omitting directory何意

    使用cp命令拷贝目录时,若该目录下有子目录 需加参数 cp -r 加目标目录到路径下

  8. LeetCode 500 Keyboard Row 解题报告

    题目要求 Given a List of words, return the words that can be typed using letters of alphabet on only one ...

  9. python之类中如何判断是函数还是方法

    通常我们认为在类中的函数为方法,类外面声明def为函数,这种说法有点片面 方法1: class Work(object): def show(self): print("执行show方法&q ...

  10. CentOS安装HBase

    1.下载HBASE http://www.apache.org/dyn/closer.cgi/hbase/ 2.解压文件到安装目录 #mkdir hbase #cd hbase #tar -zxvf ...