如何获得具有相同类型Kineticjs的儿童? [英] How to get Children that have same type Kineticjs?

查看:100
本文介绍了如何获得具有相同类型Kineticjs的儿童?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Kineticjs中遇到了麻烦,在我的代码中:

  var G1 = new Kinetic.Group()

var sq = new Kinetic.Rect({
x:0,
y:0,
name:sq
})
var line1 = new Kinetic.Line({
Points:[0,0,10,10],
name:line1
})

var line2 = new Kinetic .Line({
Points:[0,0,50,50],
name:line1
})

G1.add(sq)。添加(line1).add(line2)

我知道要让G1中的孩子只输入 G1.getChildren()。但要获得相同类型的孩子,例如类型Kinetic.Line,我不知道。
请帮助我,tahnks

解决方案

抱歉没有关于此的教程,但您可以按类型选择孩子像这样:在KineticJS中,
$ b

var shapes = layer.get('Line');



,形状类型类似于DOM标签。您可以按名称选择它们。


I have a trouble in Kineticjs, in my code:

var G1=new Kinetic.Group()

var sq=new Kinetic.Rect({
x:0,
y:0,
name:"sq"
})
var line1=new Kinetic.Line({
Points:[0,0,10,10],
name:"line1"
})

var line2=new Kinetic.Line({
Points:[0,0,50,50],
name:"line1"
})

G1.add(sq).add(line1).add(line2)

I know that to get the children from G1 just type "G1.getChildren()". But to get the children that has same type for example type Kinetic.Line I don't have any idea. Please help me, tahnks

解决方案

sorry for not having a tutorial on this, but you can select children by type like this:

var shapes = layer.get('Line');

in KineticJS, shape types are similar to DOM tags. You can select them by name.

这篇关于如何获得具有相同类型Kineticjs的儿童?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆