我无法在控制器中使用override func didMoveToView(view: SKView) {
let bkg = UIImage(named: "Background")
let backgroundCGImage = bkg!.CGImage //change the string to your image name
let coverageSize = self.size //the size of the entire image you want tiled
let textureSize = CGRectMake(0, 0, bkg!.size.width, bkg!.size.height); //the size of the tile.
UIGraphicsBeginImageContextWithOptions(coverageSize, false, UIScreen.mainScreen().scale);
let context = UIGraphicsGetCurrentContext()
CGContextDrawTiledImage(context, textureSize, backgroundCGImage)
let tiledBackground = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
let backgroundTexture = SKTexture(image: tiledBackground)
let backgroundTiles = SKSpriteNode(texture: backgroundTexture)
backgroundTiles.yScale = -1 //upon closer inspection, I noticed my source tile was flipped vertically, so this just flipped it back.
backgroundTiles.position = CGPointMake(self.size.width/2, self.size.height/2)
self.addChild(backgroundTiles)
}
进行以下代码中的某些计算:
selectedItem1
使用以下控制器:
<div class="col-md-3">
<label>Vendere:</label>
<select ng-model="selectedItem1" ng-options="(rosa.nome+' '+rosa.costo) for rosa in rose"></select>
</div>
我明白为什么?哪里我错了?
答案 0 :(得分:0)
我想你需要给selectedItem1
初始值。看看下面的例子会对你有帮助: -
var app = angular.module('App', []);
app.controller('Ctrl', function($scope, $http) {
$scope.rose = [{
'nome': "abc",
'costo':110
}, {
nome: "xyz",
costo: 10
}];
$scope.selectedItem1 = $scope.rose[0];// default selected item
$scope.budget0 = 60;
$scope.budget1 = $scope.budget0 - $scope.selectedItem1.costo;
$scope.change = function(){
$scope.budget1 = $scope.budget0 - $scope.selectedItem1.costo;
console.log($scope.selectedItem1);
console.log($scope.budget0 +"-"+ $scope.selectedItem1.costo +"="+$scope.budget1);
}
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="App" ng-controller="Ctrl">
<select ng-model="selectedItem1" ng-change="change()"
ng-options="(rosa.nome+' '+rosa.costo) for rosa in rose"></select>
<br/>
{{"budget1 == "+budget1}}
</div>
&#13;