我正在使用Sprite Builder并创建了一个scrollview来创建条带选择列表,可以水平滚动。
PlayerListContainer.ccb:Scrollview Container
PlayerListContainer.swift - 注意主要但只调用回调函数。
PlayerList.ccb:主要列表 - 取宽度,高度为300,320的CCNode PlayerList.swift
//
// PlayerList.swift
// tsb
//
// Created by Paresh Thakor on 27/12/15.
// Copyright (c) 2015 Apportable. All rights reserved.
//
import Foundation
//let Pi = CGFloat(M_PI)
//let degreesToRadians = CGFloat(Pi / 180)
//let radiansToDegrees = CGFloat(180 / Pi)
class PlayerList: CCNode {
//weak var __horizontalLayout: CCLayoutBox!
//weak var __container: CCScrollView!
weak var __node: CCNode!
var userDefaults = NSUserDefaults.standardUserDefaults()
override init!() {
super.init()
NSLog("init Player list")
}
func didLoadFromCCB() {
NSLog("Player list loaded")
__node.contentSizeType = CCSizeTypeNormalized
//__node.contentSizeInPoints = CGSizeMake(1000, 500)
__node.contentSize = CGSizeMake(3, 1)
// Add player children to select
for (var i = 0; i<20; i++) {
let playerBox = CCNodeColor(color: CCColor.redColor())
//playerBox.contentSize = CGSizeMake(50, 50)
let player = CCSprite(imageNamed: "ccbResources/playerBall.png")
playerBox.contentSize = CGSizeMake(player.contentSizeInPoints.width+20, player.contentSizeInPoints.height+20)
playerBox.position = ccp(CGFloat(5)+((playerBox.contentSizeInPoints.width+CGFloat(5)) * CGFloat(i)),5)
player.position = ccp(playerBox.contentSizeInPoints.width/2, playerBox.contentSizeInPoints.height/2)
playerBox.addChild(player)
__node.addChild(playerBox)
}
//self.contentSizeInPoints = CGSizeMake(20*50, 50)
self.userInteractionEnabled = true
self.color = CCColor(UIColor: UIColor.greenColor())
}
}
这样可行但滚动视图未显示。这将加载我们放置的无限盒子。
此滚动视图不向右滚动,等等没有任何反应。
有人可以告诉我吗?