SpriteKit PhysicsBody非矩形碰撞 [英] SpriteKit PhysicsBody non-rectangular collision

查看:91
本文介绍了SpriteKit PhysicsBody非矩形碰撞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    pipeUp.physicsBody = SKPhysicsBody(rectangleOfSize: pipeUp.size)

在此编码中,我将rectangleOfSize用于碰撞物理体,但是如果我想仅以像素的形式使用图像的形状,我应该用什么代替rectangleOfSize?

in this coding I used the rectangleOfSize for collision physics body, but if I want to use by pixel just the shape of the image, what I should use instead of rectangleOfSize?

推荐答案

您应该制作一个CGPath来作为对象的形状,并使用SKPhysicsBodyinit(polygonFromPath path: CGPath)作为

You should make a CGPath that is the shape of your object, and use SKPhysicsBody's init(polygonFromPath path: CGPath) as described here

这篇关于SpriteKit PhysicsBody非矩形碰撞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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