我想用cocos2d-x(c ++)读一个plist这里是我的plist:
<array>
<dict>
<key>x</key>
<integer>0</integer>
<key>y</key>
<integer>0</integer>
</dict>
<dict>
<key>x</key>
<integer>140</integer>
<key>y</key>
<integer>12</integer>
</dict>
<dict>
<key>x</key>
<integer>120</integer>
<key>y</key>
<integer>280</integer>
</dict>
<dict>
<key>x</key>
<integer>40</integer>
<key>y</key>
<integer>364</integer>
</dict>
<array>
Run Code Online (Sandbox Code Playgroud)
它基本上是由(x,y)坐标组成的字典数组.我原来的阅读代码是:
NSString *path = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"w%i", world] ofType:@"plist"];
NSMutableArray* points = [NSMutableArray arrayWithContentsOfFile:path];
Run Code Online (Sandbox Code Playgroud)
但现在我需要将其翻译成c ++中的cocos2d-x.我用Google搜索了一些文章,但它们都是关于将plist读入字典.我需要一个阵列.
编辑:::
现在我改变了我的plist格式:
<dict>
<key>11x</key>
<integer>0</integer>
<key>11y</key>
<integer>0</integer>
<key>12x</key>
<integer>140</integer>
<key>12y</key>
<integer>12</integer>
<dict>
Run Code Online (Sandbox Code Playgroud)
我该怎么办???我仍然得到同样的错误:
CCDictionary<std::string, CCObject*>* dict = CCFileUtils::dictionaryWithContentsOfFile(plistPath);
int x = (int)dict->objectForKey("11x");
int y = (int)dict->objectForKey("11y");
Run Code Online (Sandbox Code Playgroud)
不行.请先试一试.看看你是否可以从样本plist中读取一个int
我的cocos2d-x游戏在进入后台时崩溃了.这是来自AppDelegate的一些代码:
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground()
{
CCDirector::sharedDirector()->pause();
CCUserDefault::sharedUserDefault()->flush();
CocosDenshion::SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->resume();
CocosDenshion::SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}
Run Code Online (Sandbox Code Playgroud)
和错误消息:
libGPUSupportMercury.dylib`gpus_ReturnNotPermittedKillClient:
0x3797e094: trap
0x3797e096: nop
Run Code Online (Sandbox Code Playgroud)
请注意,iPhone总是崩溃,但Android上99%崩溃(当游戏没有加载大图像时等等)
编辑:我已经尝试过CCDirector :: sharedDirector() - > stopAnimation(),它适用于iOS.但仍然崩溃的Android(不是立即.当返回到应用程序时,屏幕变黑(但我认为它仍然在运行,因为背景音乐仍在播放.然后大约5秒后它崩溃)
编辑2:Eclipse中的错误消息:
libEGL call to OpenGL ES API with no current context (logged once per thread) (red warning text)
libc Fatal signal 11 …Run Code Online (Sandbox Code Playgroud) 我有以下代码.该response.result.value类型是Optional(AnyObject),我要检查
[[String: AnyObject]]如果...返回...声明,我更喜欢一个线卫
Alamofire.request(.GET, API.listArticle).responseJSON {
response in
print(response.result.value)
guard let articles = response.result.value as? [[String: AnyObject]] where articles.count > 0 else {
return
}
for article in articles {
let entity = NSEntityDescription.insertNewObjectForEntityForName("Article", inManagedObjectContext: DBHelper.context()) as! Article
entity.title = article["title"]
entity.content = article["content"]
}
}
Run Code Online (Sandbox Code Playgroud)错误是article["content"]行,
cannot subscript a value of type Dictionary<String, AnyObject> with an index of type String.
我还需要检查是否title存在article?它会崩溃还是什么都不做?
我试图从头开始构建一个nginx图像(而不是使用官方的nginx图像)
FROM ubuntu
RUN apt-get update
RUN apt-get install -y nginx
RUN rm -v /etc/nginx/nginx.conf
ADD nginx.conf /etc/nginx/
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
EXPOSE 80
COPY ./files/ /var/www/html/
CMD service nginx start
Run Code Online (Sandbox Code Playgroud)
这是我nginx.conf在当前目录下的文件.
server {
root /var/www/html
location / {
index.html
}
}
Run Code Online (Sandbox Code Playgroud)
我的虚拟index.html文件在./files文件夹下
<p1>hello world</p1>
Run Code Online (Sandbox Code Playgroud)
我运行这个命令
docker build -t hello-world .
Run Code Online (Sandbox Code Playgroud)
和
docker run -p 80:80 hello-world
Run Code Online (Sandbox Code Playgroud)
但是我说错了
* Starting nginx nginx
...fail!
Run Code Online (Sandbox Code Playgroud)
可能是什么问题?
我刚刚完成了我的iPad版本(全部和精简版)我的游戏Let's Spot It.他们使用不同的捆绑种子ID.(就像不同的应用程序)然后我想在其iPhone版本上工作.但我无法找到"生成新的"捆绑种子ID的选项.
Bundle Seed ID (App ID Prefix)
Use your Team ID or select an existing Bundle Seed ID for your App ID.
Run Code Online (Sandbox Code Playgroud)
发生了什么?我没有使用高级技术,比如在我的两个应用之间共享数据.所以我可以使用与其他应用程序相同的应用程序ID(与此应用程序无关),或者我可以只使用团队捆绑种子ID吗?如果我使用团队ID,我应该在我的xcode项目中做什么?
我正在关注我的涂鸦应用程序的本教程.
http://www.raywenderlich.com/18840/how-to-make-a-simple-drawing-app-with-uikit
他的擦除功能是使用白色绘图.但我正在使用图像背景,当我擦除时,我真的需要擦除.
我试过了
CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeClear);
Run Code Online (Sandbox Code Playgroud)
但它不起作用.这是我的代码:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
_mouseSwiped = NO;
UITouch *touch = [touches anyObject];
_lastPoint = [touch locationInView:self.tempImageView];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
_mouseSwiped = YES;
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.tempImageView];
UIGraphicsBeginImageContext(self.tempImageView.frame.size);
[self.tempImageView.image drawInRect:CGRectMake(0, 0, self.tempImageView.frame.size.width, self.tempImageView.frame.size.height)];
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), _lastPoint.x, _lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), _width );
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), _red, _green, _blue, 1.0);
if (_isErasing) {
CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeClear);
}
else {
CGContextSetBlendMode(UIGraphicsGetCurrentContext(),kCGBlendModeNormal);
}
CGContextStrokePath(UIGraphicsGetCurrentContext());
self.tempImageView.image = …Run Code Online (Sandbox Code Playgroud) 我正在将所有游戏迁移到cocos2d 3.0.我稍微修改了SlidingMenuGrid.m.
SlidingMenuGrid.h:
//
// SlidingMenuGrid
//
// Created by Brandon Reynolds on 1/9/11.
#import "cocos2d.h"
@interface SlidingMenuGrid : CCLayer
{
tCCMenuState state; // State of our menu grid. (Eg. waiting, tracking touch, cancelled, etc)
CCMenuItem *selectedItem; // Menu item that was selected/active.
CGPoint padding; // Padding in between menu items.
CGPoint menuOrigin; // Origin position of the entire menu grid.
CGPoint touchOrigin; // Where the touch action began.
CGPoint touchStop; // Where the touch action stopped.
int iPageCount; // …Run Code Online (Sandbox Code Playgroud) 我使用angular custom directive来实现bootstrap navbar.这是我的代码:
"use strict";
var helper = require('../helper.js')
var app = angular.module('custom_directive')
app.directive('tagNavbar', [function() {
return {
restrict: 'E',
scope: {
},
templateUrl: '/public/common/tag_navbar.html',
controller:
['$scope', '$window', 'userService',
function($scope, $window, userService) {
var curUrl = $window.location.pathname + $window.location.hash
//client url is used in <a href>, redirect purpose
$scope.signinClientUrl = helper.urlWithQuery('/auth#!/signin', {redirect:curUrl})
$scope.signupClientUrl = helper.urlWithQuery('/auth#!/signup', {redirect:curUrl})
//server url is used for rest api, like <form action>
//if signout success, better to redirect to home, since some page are not …Run Code Online (Sandbox Code Playgroud) 我有以下代码来获取对评论列表的回复.(1条评论有很多回复)
static func fetchCommentsAndTheirReplies(articleId: String, failure: (()->Void)?, success: (comments: [[String: AnyObject]], replies: [[[String: AnyObject]]], userIds: Set<String>)->Void) {
var retComments = [[String: AnyObject]]()
var retReplies = [[[String: AnyObject]]]()
var retUserIds = Set<String>()
Alamofire.request(.GET, API.listComment, parameters: [API.articleId: articleId]).responseJSON {
response in
guard let comments = response.result.value as? [[String: AnyObject]] else {
failure?()
return
}
print(comments)
retComments = comments
let group = dispatch_group_create()
for (commentIndex, comment) in comments.enumerate() {
guard let id = comment["_id"] as? String else {continue}
let relevantUserIds = parseRelaventUserIdsFromEntity(comment)
for …Run Code Online (Sandbox Code Playgroud) 我有一个 UIKit 应用程序,我使用 UIHostingController 将一些屏幕迁移到 SwiftUI。我曾经能够重复使用 UIKit 的相同导航栏。但在切换到 NavigationStack API 后,我无法复制相同的行为。
这是完整的可重现代码。
import UIKit
import SwiftUI
struct ListView: View {
@State var selectedString: String? = nil
var body: some View {
let details = ["foo", "bar", "baz"]
// No need to wrap under NavigationView, otherwise will have double Nav Bar
// This will use the UIKit's nav bar
List {
ForEach(details, id: \.self) { detail in
let destination = Text("This is a detailed page for \(detail)")
.navigationTitle("Detail page")
NavigationLink(
detail, …Run Code Online (Sandbox Code Playgroud)