当我尝试在 xcode 模拟器中测试我的游戏时,我在下面收到这些错误。任何人都知道出了什么问题。顺便说一句,如果演员与物体碰撞,则行为是解锁新关卡:
第 49 行错误:“objc_object*”和“float”类型的无效操作数转为二进制
第 58 行错误:“objc_object*”和“float”类型的无效操作数转为二进制
第 73 行错误:iso c++ 禁止指针和整数之间的比较
这是 IOS 代码: 第 49 行:
if(([mActor touchedActor] && ([self getGameAttribute:@"Highest Level Completed"] >= [self asNumber:[NSNumber numberWithFloat:_levelnumber]])))
第 58 行:
if(([self getGameAttribute:@"Highest Level Completed"] >= [self asNumber:[NSNumber numberWithFloat:_levelnumber]]))
第 73 行:
if(([mActor touchedActor] && (([self getGameAttribute:@"Highest Level Completed"] <= 5) && [[Game game] purchasedProduct:@"MyID"])))
该行为的所有代码:
#import <Box2D/Box2D.h>
#import <AudioToolbox/AudioServices.h>
#import <Foundation/Foundation.h>
#import "ActorScript.h"
#import "Script.h"
#import "Actor.h"
#import "ActorType.h"
#import "Assets.h"
#import "Behavior.h"
#import "Collision.h"
#import "CollisionPoint.h"
#import "Game.h"
#import "GameModel.h"
#import "GroupDef.h"
#import "FadeInTransition.h"
#import "FadeOutTransition.h"
#import "Region.h"
#import "Runnable.h"
#import "Scene.h"
#import "SHThumbstick.h"
#import "Sparrow.h"
#import "Transition.h"
@interface Design_190_190_Clicktoplaylevel : ActorScript
{
@public
NSString* tempHolder;
Scene* _Scenetoplay;
NSString* _Levellabel;
float _levelnumber;
}
@end
@implementation Design_190_190_Clicktoplaylevel
-(void)load
{
[self addWhenUpdatedListener:nil func:^(NSMutableArray* list, Script* theScript){
Design_190_190_Clicktoplaylevel* self = (Design_190_190_Clicktoplaylevel*) theScript;
if(([mActor touchedActor] && ([self getGameAttribute:[self asNumber:[NSNumber numberWithFloat:[[self getGameAttribute:@"Highest Level Completed"] floatValue]]]] >= [self asNumber:[NSNumber numberWithFloat:_levelnumber]])))
{
[self setGameAttribute:[[self getGameAttribute:@"Current Level"] floatValue] value:[NSNumber numberWithFloat:[self asNumber:[NSNumber numberWithFloat:_levelnumber]]]];
[self switchScene:_Scenetoplay.ID leave:[self createFadeOut:((1000*1)) color:0] enter:[self createFadeIn:((1000*1)) color:0]];
}
}];
[self addWhenDrawingListener:nil func:^(SPRenderSupport* g, int x, int y, BOOL screen, NSMutableArray* list, Script* theScript){
Design_190_190_Clicktoplaylevel* self = (Design_190_190_Clicktoplaylevel*) theScript;
if(([self getGameAttribute:[self asNumber:[NSNumber numberWithFloat:[[self getGameAttribute:@"Highest Level Completed"] floatValue]]]] >= [self asNumber:[NSNumber numberWithFloat:_levelnumber]]))
{
[mActor setAnimation:@"Animation 1"];
[[Game game] setFont:[ self getFont:52] size:1];
[[Game game] drawString:_Levellabel x:(([mActor getWidth] - [[Game game] getWidthForString:[ self getFont:52] string:_Levellabel]) / 2) y:30];
}
else
{
[mActor setAnimation:@"Animation 0"];
}
}];
[self addWhenUpdatedListener:nil func:^(NSMutableArray* list, Script* theScript){
Design_190_190_Clicktoplaylevel* self = (Design_190_190_Clicktoplaylevel*) theScript;
if(([mActor touchedActor] && (([self getGameAttribute:[self asNumber:[NSNumber numberWithFloat:[[self getGameAttribute:@"Highest Level Completed"] floatValue]]]] <= [self asNumber:[NSNumber numberWithFloat:5]]) && [[Game game] purchasedProduct:@"MyID"])))
{
[self setGameAttribute:[[self getGameAttribute:@"Current Level"] floatValue] value:[NSNumber numberWithFloat:[self asNumber:[NSNumber numberWithFloat:_levelnumber]]]];
[self switchScene:_Scenetoplay.ID leave:[self createFadeOut:((1000*1)) color:0] enter:[self createFadeIn:((1000*1)) color:0]];
}
else if((([mActor touchedActor] && [self sameAs:[self getGameAttribute:[self asNumber:[NSNumber numberWithFloat:[[self getGameAttribute:@"Highest Level Completed"] floatValue]]]] two:[NSNumber numberWithFloat:[self asNumber:[NSNumber numberWithFloat:5]]]]) && !([[Game game] purchasedProduct:@"MyID"])))
{
return;
}
}];
}
-(void)forwardMessage:(NSString*)msg
{