Hello GLBASIC community,I just want to invite you to try my 8080 Arcade Emulator http://apd-games.com/emulator.html and see my my new app for iOS and Android DEFENDER 1 http://apd-games.com/.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuote*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.9.829 SN:b4f5b7db - 3D, NET
"Vectors1-10.gbas"(207) error : wrong argument type :
http://www.glbasic.com/forum/index.php?topic=8048.msg67541#msg67541
PVector mouse = new PVector(mouseX,mouseY);
PVector dir = PVector.sub(mouse,location);
TYPE TObject
x#
y#
z#
FUNCTION set: x, y
self.x = x
self.y = y
ENDFUNCTION
FUNCTION add: v AS TObject
self.x = self.x + v.x
self.y = self.y + v.y
ENDFUNCTION
FUNCTION subv: v AS TObject
self.x = self.x - v.x
self.y = self.y - v.y
ENDFUNCTION
FUNCTION subv2: v1 AS TObject, v2 AS TObject
v1.x = v1.x - v2.x
v1.y = v1.y - v2.y
RETURN v1 /// <====== THIS GENERATES THE ERROR
ENDFUNCTION
TYPE Tparticle
x=0
y=0
sine=0
cosine=0
speed=0
life#=0.0
colors=0 //points to array of colors
ENDTYPE
compiling:
C:\Users\ACARVA~1\AppData\Local\Temp\glbasic\gpc_temp0.cpp: In function `int __GLBASIC__::__MainGameSub_()':
C:\Users\ACARVA~1\AppData\Local\Temp\glbasic\gpc_temp0.cpp:65: error: invalid initialization of non-const reference of type '__GLBASIC__::DGNatArray&' from a temporary of type 'int'
C:/Program Files (x86)/GLBasic_v11/Compiler/platform/Include/glb.h:1370: error: in passing argument 1 of `DGNat __GLBASIC__::MEM2SPRITE(__GLBASIC__::DGNatArray&, DGNat, DGNat, DGNat)'
*** FATAL ERROR - Please post this output in the forum
LOCAL w%, h%, pix%[]
IF LOADSPRITEMEM("test.png", w%, h%, pix%[])
MEM2SPRITE(0, w%, h%, pix%[])
DRAWSPRITE 0,0,0
ENDIF
SHOWSCREEN
MOUSEWAIT
IMPORT "C" void iOSMessageBox(const char*,const char*, const char*, const char*)
IMPORT "C" const char* GetiOSMessageBoxValues()
GLOBAL MENSAJE$
// El nuevo símbolo de separación para los parámetros a pasar a la función es la "tubería", antes era $, en mi código anterior...
iOSMessageBox("Título","Mensaje" + CHR$(0xD) + CHR$(0xD) + CHR$(0xD) + CHR$(0xD), "Esto es una prueba ü Ñ |:P", "Aceptar|Cancelar")
LOCAL InstanteComienzo% = GETTIMERALL()
MENSAJE$ = ""
WHILE MENSAJE$ = ""
SLEEP 500
WHILE ABS(GETTIMERALL() - InstanteComienzo%) < 500
HIBERNATE
WEND
MENSAJE$ = GetiOSMessageBoxValues()
WEND
PRINT MENSAJE$, 100, 100
SHOWSCREEN
HIBERNATE
MOUSEWAIT
iOSMessageBox("Título","Mensaje" + CHR$(0xD) + CHR$(0xD), "Esto es otra prueba", "Aceptar|Cancelar")
InstanteComienzo% = GETTIMERALL()
MENSAJE$ = ""
WHILE MENSAJE$ = ""
SLEEP 500
WHILE ABS(GETTIMERALL() - InstanteComienzo%) < 500
HIBERNATE
WEND
MENSAJE$ = GetiOSMessageBoxValues()
WEND
PRINT MENSAJE$, 100, 100
SHOWSCREEN
HIBERNATE
MOUSEWAIT
#if defined (TARGET_OS_IPHONE)
// UIALERT
//#import <UIKit/UIAlert.h> // No es necesario duplicar la importación hecha con anterioridad
@interface GLBasicMessageBoxer: NSObject <UIAlertViewDelegate>
{
// Declaración de los punteros para los elementos comunes
UITextField* txtObject;
NSMutableArray* resObjects;
NSString* resValues;
NSString* pTitle,* pMessage,* pLabels,* pButtons;
}
@end
@implementation GLBasicMessageBoxer
// Llamada necesaria para llamar al código que muestra el Alert en el proceso principal
- (void)showAlertCaller:(NSString*)cTitle andMessage:(NSString*)cMessage andLabels:(NSString*)cLabels andButtons:(NSString*)cButtons
{
// Introducción de los valores pasados como parámetro punteros accesibles por "showAlert"
pTitle = [[NSString alloc] initWithString:cTitle];
pMessage = [[NSString alloc] initWithString:cMessage];
pLabels = [[NSString alloc] initWithString:cLabels];
pButtons = [[NSString alloc] initWithString:cButtons];
// Llamada a "showAlert" enviándola al proceso principal
[self performSelectorOnMainThread:@selector(showAlert) withObject:nil waitUntilDone:NO];
}
- (void)showAlert
{
// Creación de la vista para el Alert
UIAlertView* alert = [[UIAlertView alloc] init];
alert.title = pTitle;
alert.message = pMessage;
alert.delegate = self;
// Anulación de la asignación de la función de cancelar al botón con índice 0
alert.cancelButtonIndex = -1;
// Creación de la matriz de botones introduciendo valores según los parámetros pasados separados por "|"
NSArray* aButtons = [pButtons componentsSeparatedByString:@"|"];
// Creación de cada botón a partir de cada valor de la matriz
for (NSString* iObject in aButtons){
[alert addButtonWithTitle:iObject];
}
// Creación de la matriz de controles de texto introduciendo valores según los parámetros pasados separados por "|"
if (pLabels != @"") {
double iPos = 70.0;
NSArray* aLabels = [pLabels componentsSeparatedByString:@"|"];
resObjects = [[NSMutableArray alloc] init];
// Creación de cada control de texto con las propiedades adecuadas asegurando que no devuelve un valor "(null)" mediante .text = @""
for (NSString* iObject in aLabels){
txtObject = [[UITextField alloc] init];
txtObject.frame = CGRectMake(12.0, iPos, 260.0, 25.0);
txtObject.text = @"";
txtObject.placeholder = iObject;
txtObject.backgroundColor = [UIColor whiteColor];
txtObject.clearButtonMode = UITextFieldViewModeWhileEditing;
txtObject.keyboardType = UIKeyboardTypeAlphabet;
txtObject.keyboardAppearance = UIKeyboardAppearanceAlert;
txtObject.autocapitalizationType = UITextAutocapitalizationTypeNone;
txtObject.autocorrectionType = UITextAutocorrectionTypeNo;
txtObject.borderStyle = UITextBorderStyleLine;
// Colocación del foco si es el primer control creado para introducción de texto
if ([aLabels indexOfObject:iObject] == 0) {
[txtObject becomeFirstResponder];
// El teclado aparece automáticamente al colocar el foco en un control de texto
}
// Aumentar el valor de la variable que controla la coordenada de posición del "top" de cada control de texto
iPos = iPos + 30.0;
// Asociación de cada control a la matriz mutable
[resObjects addObject:txtObject];
// XCode soporta añadir controles de texto directamente a un Alert pero Apple no permite su uso directo al no estar documentado
// Para poder imitar el comportamiento pueden agregarse "subvistas" al Alert e introducir los controles necesarios en ellas
[alert addSubview:txtObject];
[txtObject release];
txtObject = nil;
}
}
[alert show];
[alert release];
}
// Recogida del botón pulsado en la memoria mediante la propiedad "delegate" (= self) asignada en "showAlert"
- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
resValues = [[NSString alloc] initWithFormat:@"%d", buttonIndex];
}
// Código que obtiene y trata los valores para construir el resultado mediante valores separados por "|"
- (void)getValues
{
// Agregado a la cadena del botón pulsado de los valores de cada control de texto en el Alert
for (UITextField* iObject in resObjects){
// Insertar el texto recogido del control en un NSMutableString
NSMutableString* tmpObjectValue = [[NSMutableString alloc] initWithString:iObject.text];
// Reemplazar el caracter usado en el código como separador de valores si el usuario lo ha introducido en los controles
[tmpObjectValue replaceOccurrencesOfString:@"|" withString:@"!" options:0 range:NSMakeRange(0, [tmpObjectValue length])];
// Agregar el valor obtenido al contenido anterior de la memoria
resValues = [resValues stringByAppendingFormat:@"|%@", tmpObjectValue];
// Liberar la memoria
[tmpObjectValue release];
tmpObjectValue = nil;
}
// Creación de otro puntero "NSData" temporal para albergar los valores obtenidos transformados para evitar errores por "encodings"
NSData* tmpValuesEncoded = [[NSData alloc] init];
// Conversión de la cadena obtenida a un "encoding" Windows Latin obviando los caracteres no reconocidos mediante "allowLossyConversion"
tmpValuesEncoded = [resValues dataUsingEncoding:NSWindowsCP1252StringEncoding allowLossyConversion:YES];
// Reintroducción de la cadena final convertida al "encoding" adecuado para que pueda devolverse desde "getValuesCaller"
resValues = [[NSString alloc] initWithData:tmpValuesEncoded encoding:NSWindowsCP1252StringEncoding];
// Liberar la memoria
tmpValuesEncoded = nil;
}
// Obtención de los valores del botón pulsado y texto introducido en los controles recuperando los valores desde el proceso principal
- (const char*)getValuesCaller
{
// Comprobación de si se ha pulsado un botón del Alert
if (resValues != nil){
// Llamada a "getValues" en el proceso principal
[self performSelectorOnMainThread:@selector(getValues) withObject:nil waitUntilDone:YES];
// Devolvemos el valor de la cadena preparada desde "getValues"
return [resValues cStringUsingEncoding:NSWindowsCP1252StringEncoding];
// Liberar la memoria
[resObjects release];
resObjects = nil;
[resValues release];
resValues = nil;
[pTitle release];
pTitle = nil;
[pMessage release];
pMessage = nil;
[pLabels release];
pLabels = nil;
[pButtons release];
pButtons = nil;
[self release];
[super dealloc];
}
else
{
// Si no se ha pulsado ningún botón se devuelve una cadena vacía
return "";
}
}
@end
// Creación del puntero para las funciones contenidas en "GLBasicMessageBoxer" a usar cada vez que se requiera un Alert
GLBasicMessageBoxer* newAlert;
// Creación de función "externalizada" a usar desde GLBasic (los parámetros "labels" y "buttons" pueden contener varios valores separados con "$")
extern "C" void iOSMessageBox(const char* cTitle, const char* cMessage, const char* cLabels, const char* cButtons)
{
newAlert = [[GLBasicMessageBoxer alloc] init];
// Conversión de tipos "C" a "NSString" al recuperar los parámetros enviados desde GLBasic y lanzado del Alert
[newAlert showAlertCaller:[NSString stringWithCString:cTitle encoding:NSASCIIStringEncoding] andMessage:[NSString stringWithCString:cMessage encoding:NSASCIIStringEncoding] andLabels:[NSString stringWithCString:cLabels encoding:NSASCIIStringEncoding] andButtons:[NSString stringWithCString:cButtons encoding:NSASCIIStringEncoding]];
}
// Creación de la función "externalizada" a usar desde GLBasic (los parámetros devueltos son valores separados con "$")
extern "C" const char* GetiOSMessageBoxValues()
{
// Se recuperan en primer lugar el índice de botón pulsado y a continuación los textos introducidos en los controles generados
return [newAlert getValuesCaller];
}
// FIN UIALERT
#endif
tempmsg$ = LTRIM$(msg$ ,"<![CDATA[")
tempmsg$ = REPLACE$(tempmsg$ ,"<![CDATA[","")
SUB GLB_ON_QUIT:
GOSUB saveGame
debu ("QUIT")
ENDSUB
SUB GLB_ON_PAUSE:
OSPaused=TRUE
debu ("PAUSE")
ENDSUB
SUB GLB_ON_RESUME:
OSPaused=FALSE
debu ("RESUMED")
ENDSUB
FUNCTION debu: data_in$
?IFDEF IPHONE
STDOUT "[GLB]->" + data_in$ + "\n"
?ELSE
DEBUG "[GLB]->" + data_in$ + "\n"
?ENDIF
ENDFUNCTION