Hello,
I have a problem with my device. I created a layout. It works fine with the emulator. But when I export the project to my GS3 the image view disapear.
What can I do ? I try to delete the buttons to see if the picture appear but it doesn't work.
My picture is in a png format.
Thank you
//Obtenir les dimensions de l'écran
Display display = getWindowManager().getDefaultDisplay();
int largeur = display.getWidth();
int hauteur= display.getHeight();
int orientation = display.getOrientation();
if (orientation==1 || orientation==3)
{
LinearLayout accueil = new LinearLayout(this);// création de la page d'accueil sans passer par les xml
accueil.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
accueil.setBackgroundColor(0xFF6E2524);
accueil.setOrientation(LinearLayout.VERTICAL);
TextView title = new TextView(this);//creation du titre
LayoutParams lparams1 = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
title.setLayoutParams(lparams1);//fixer largeur hauteur
title.setGravity(Gravity.CENTER);
title.setTextColor(0xFFFFFFFF);
title.setText("Toucher pour créer");
title.setTextSize(TypedValue.COMPLEX_UNIT_PX, hauteur*8/100);//réglage pour adapter le texte à la taille de l'écran
accueil.addView(title); // ajout au layout principal
Button b1 = new Button(this);
LinearLayout.LayoutParams lparams2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lparams2.setMargins(largeur/8, hauteur/18, largeur/8, 0); //fixe les marges
b1.setLayoutParams(lparams2);//fixer largeur hauteur
b1.setMinimumWidth(largeur*8/10);//fixe la largeur minimal
b1.setBackgroundColor(0xFFB7C025);
b1.setGravity(Gravity.CENTER);
b1.setTextColor(0xFFFFFFFF);
b1.setText("Galerie des oeuvres");
b1.setTextSize(TypedValue.COMPLEX_UNIT_PX, hauteur*5/100);//réglage pour adapter le texte à la taille de l'écran
accueil.addView(b1); // ajout au layout principal
Button b2 = new Button(this);
LinearLayout.LayoutParams lparams3 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lparams3.setMargins(largeur/8, hauteur/18, largeur/8, 0); //fixe les marges
b2.setLayoutParams(lparams3);//fixer largeur hauteur
b2.setMinimumWidth(largeur*8/10);//fixe la largeur minimal
b2.setBackgroundColor(0xFFB7C025);
b2.setGravity(Gravity.CENTER);
b2.setTextColor(0xFFFFFFFF);
b2.setText("Prise en main");
b2.setTextSize(TypedValue.COMPLEX_UNIT_PX, hauteur*5/100);//réglage pour adapter le texte à la taille de l'écran
accueil.addView(b2); // ajout au layout principal
Button b3 = new Button(this);
LinearLayout.LayoutParams lparams4 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lparams4.setMargins(largeur/8, hauteur/18, largeur/8, 0); //fixe les marges
b3.setLayoutParams(lparams4);//fixer largeur hauteur
b3.setMinimumWidth(largeur*8/10);//fixe la largeur minimal
b3.setBackgroundColor(0xFFB7C025);
b3.setGravity(Gravity.CENTER);
b3.setTextColor(0xFFFFFFFF);
b3.setText("Quitter");
b3.setTextSize(TypedValue.COMPLEX_UNIT_PX, hauteur*5/100);//réglage pour adapter le texte à la taille de l'écran
accueil.addView(b3); // ajout au layout principal
ImageView logo = new ImageView(this);
LinearLayout.LayoutParams lparams5 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, hauteur/15);//calculer pour garder le ratio 1/2
lparams5.setMargins(largeur/18, hauteur/18, 0, 0); //fixe les marges
logo.setLayoutParams(lparams5);
logo.setAdjustViewBounds(true);
logo.setImageResource(R.drawable.logo);
accueil.addView(logo);//ajout au layout ppl
setContentView(accueil);//mise en place du layout accueil
}
else
{
LinearLayout accueil = new LinearLayout(this);// création de la page d'accueil sans passer par les xml
accueil.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
accueil.setBackgroundColor(0xFF6E2524);
accueil.setOrientation(LinearLayout.VERTICAL);
TextView title = new TextView(this);//creation du titre
LayoutParams lparams1 = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
title.setLayoutParams(lparams1);//fixer largeur hauteur
title.setGravity(Gravity.CENTER);
title.setTextColor(0xFFFFFFFF);
title.setText("Toucher pour créer");
title.setTextSize(TypedValue.COMPLEX_UNIT_PX, largeur*8/100);//réglage pour adapter le texte à la taille de l'écran
accueil.addView(title); // ajout au layout principal
Button b1 = new Button(this);
LinearLayout.LayoutParams lparams2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lparams2.setMargins(largeur/8, hauteur/8, largeur/8, 0); //fixe les marges
b1.setLayoutParams(lparams2);//fixer largeur hauteur
b1.setMinimumWidth(largeur*8/10);//fixe la largeur minimal
b1.setBackgroundColor(0xFFB7C025);
b1.setGravity(Gravity.CENTER);
b1.setTextColor(0xFFFFFFFF);
b1.setText("Galerie des oeuvres");
b1.setTextSize(TypedValue.COMPLEX_UNIT_PX, largeur*6/100);//réglage pour adapter le texte à la taille de l'écran
accueil.addView(b1); // ajout au layout principal
Button b2 = new Button(this);
LinearLayout.LayoutParams lparams3 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lparams3.setMargins(largeur/8, hauteur/8, largeur/8, 0); //fixe les marges
b2.setLayoutParams(lparams3);//fixer largeur hauteur
b2.setMinimumWidth(largeur*8/10);//fixe la largeur minimal
b2.setBackgroundColor(0xFFB7C025);
b2.setGravity(Gravity.CENTER);
b2.setTextColor(0xFFFFFFFF);
b2.setText("Prise en main");
b2.setTextSize(TypedValue.COMPLEX_UNIT_PX, largeur*6/100);//réglage pour adapter le texte à la taille de l'écran
accueil.addView(b2); // ajout au layout principal
Button b3 = new Button(this);
LinearLayout.LayoutParams lparams4 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lparams4.setMargins(largeur/8, hauteur/8, largeur/8, 0); //fixe les marges
b3.setLayoutParams(lparams4);//fixer largeur hauteur
b3.setMinimumWidth(largeur*8/10);//fixe la largeur minimal
b3.setBackgroundColor(0xFFB7C025);
b3.setGravity(Gravity.CENTER);
b3.setTextColor(0xFFFFFFFF);
b3.setText("Quitter");
b3.setTextSize(TypedValue.COMPLEX_UNIT_PX, largeur*6/100);//réglage pour adapter le texte à la taille de l'écran
accueil.addView(b3); // ajout au layout principal
ImageView logo = new ImageView(this);
LinearLayout.LayoutParams lparams5 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, hauteur/20);//calculer pour garder le ratio 1/2
lparams5.setMargins(largeur/18, hauteur/18, 0, 0); //fixe les marges
logo.setLayoutParams(lparams5);
logo.setAdjustViewBounds(true);
logo.setImageResource(R.drawable.logo);
accueil.addView(logo);//ajout au layout ppl
setContentView(accueil);//mise en place du layout accueil
}
Related
I made a table with Itext7 using the Table object and inserted into a Canvas object.
This is the table :
Now I would like to rotate the table (but not the page) to achieve this:
How can I rotate the Table or Canvas 270 degrees.
This is the code I use to generate the table (It is part of a larger project, however this is the method that generates the table) :
num_row = num_row + 1; // Indica il numero di riga della tabella
PdfDocument_Configurazione_Text cfgText;
if (intestazione) {
cfgText = cfg.getCfg_intestazione();
} else {
cfgText = cfg.getCfg_riga();
}
if (cfgText == null) {
throw new Exception("Configurazione testo " + (intestazione ? "intestazione" : "riga") + " null");
}
campi = campi == null ? new ArrayList<>() : campi;
Paragraph p;
PdfFont font = PdfFontFactory.createFont(cfgText.getTipo_font_testo());
table = new Table(cfg.getTabella_num_col());
for (int i = 1; i <= cfg.getTabella_num_col(); i++) {
Cell cell = new Cell();
p = new Paragraph("");
String str = campi.size() < i ? " " : campi.get(i - 1);
p.add(str);
p.setFont(font);
p.setFontSize(cfgText.getDim_font_testo());
if (cfgText.isTesto_bold()) {
p.setBold();
}
if (cfgText.isTesto_italic()) {
p.setItalic();
}
if (cfgText.isTesto_sottolineato()) {
p.setUnderline();
}
if (intestazione) {
if (cfg.getCol_int_border().containsKey(num_row)) { // Se nella mappa è presente il numero di riga per settaggio bordo
for (List border : UtilConvertListMap.convertListBorder(cfg.getCol_int_border().get(num_row))) { // Ciclo all'interno di una lista alla ricerca del bordo
if (border.get(0).equals(String.valueOf(i - 1))) { // Se nella lista è presente un numero di colonna uguale a quello che sta disegnando il programma
switch (border.get(1).toString().trim()) { // setto i relativi bordi per singola cella
case "BUTTOM":
if (border.get(2).toString().trim().equals("false")) {
cell.setBorderBottom(Border.NO_BORDER);
}
case "TOP":
if (border.get(2).toString().trim().equals("false")) {
cell.setBorderTop(Border.NO_BORDER);
}
case "LEFT":
if (border.get(2).toString().trim().equals("false")) {
cell.setBorderLeft(Border.NO_BORDER);
}
case "RIGHT":
if (border.get(2).toString().trim().equals("false")) {
cell.setBorderRight(Border.NO_BORDER);
}
}
}
}
}
} else { // per le righe dati manipolo solo bordi colonne le righe saranno tutte uguali
if (cfg.getCol_dati_border((i - 1), "BUTTOM") == false) {
cell.setBorderBottom(Border.NO_BORDER);
}
if (cfg.getCol_dati_border((i - 1), "TOP") == false) {
cell.setBorderTop(Border.NO_BORDER);
}
if (cfg.getCol_dati_border((i - 1), "LEFT") == false) {
cell.setBorderLeft(Border.NO_BORDER);
}
if (cfg.getCol_dati_border((i - 1), "RIGHT") == false) {
cell.setBorderRight(Border.NO_BORDER);
}
}
if (intestazione) {
cell.setTextAlignment(TextAlignment.valueOf(cfg.getCol_int_allign(num_row, (i - 1)).toString()));
} else {
cell.setTextAlignment(cfg.getCol_dati_allign(i - 1, intestazione));
}
if (intestazione) {
p.setWidth((float) cfg.getCol_int_width(num_row, (i - 1)));
} else {
p.setWidth((float) cfg.getCol_dati_width(i - 1));
}
cell.setWidth(p.getWidth());
cell.add(p);
p.setProperty(Property.OVERFLOW_X, OverflowPropertyValue.valueOf("FIT"));
table.setHeight((float) cfg.getRig_heigth());
if (intestazione) {
table.addCell(cell);
} else {
table.addCell(cell);
}
}
MinMaxWidth minMaxWidth = ((TableRenderer) table.createRendererSubTree().setParent(canvas.getRenderer())).getMinMaxWidth();
float minWidth = minMaxWidth.getMinWidth();
float maxWidth = minMaxWidth.getMaxWidth();
rectangle.setWidth(maxWidth);
canvas.add(table);
table.flushContent();
This piece of code generates the canvas :
cfg = cfgn;
pages = pdfDocument.getPage(numero_pagina);
pdfCanvas = new PdfCanvas(pages);
rectangle = new Rectangle(cfg.getPos_x_tabella(), cfg.getPos_y_tabella(), 100, 200);
canvas = new Canvas(pdfCanvas, rectangle);
canvas.setBorder(Border.NO_BORDER);
The first idea would be to set the RotationAngle property of the table
table.setRotationAngle(-Math.PI/2);
canvas.add(table);
(RotateSomeContent test testForDropVidProperty)
Unfortunately this property currently (7.2.4-SNAPSHOT) seems not to be supported by the Table class.
What you can always do, though, is rotate the PdfCanvas on which the table is drawn, e.g. like this:
PdfCanvas pdfCanvas = new PdfCanvas(page);
// Rectangle for the table in upright page coordinates
Rectangle rectangle = new Rectangle(100, 100, 400, 700);
// show rectangle area
pdfCanvas.saveState();
pdfCanvas.setFillColor(new DeviceRgb(255, 255, 128));
pdfCanvas.rectangle(rectangle);
pdfCanvas.fill();
pdfCanvas.restoreState();
// apply a translation and a rotation so that the table will be rotated
// and the origin will be in the lower left corner of the rectangle
AffineTransform transform = AffineTransform.getTranslateInstance(rectangle.getLeft(), rectangle.getTop());
transform.rotate(-Math.PI/2);
pdfCanvas.concatMatrix(transform);
Rectangle rotatedRectangle = new Rectangle(0, 0, rectangle.getHeight(), rectangle.getWidth());
try ( Canvas canvas = new Canvas(pdfCanvas, rotatedRectangle) ) {
Table table = new Table(5);
table.addHeaderCell("DEBITO");
table.addHeaderCell("INTERESSI DI MORA");
table.addHeaderCell("ONERI DI RISCOSSIONE");
table.addHeaderCell("SPESE DI NOTIFICA\nE ACCESSORI");
table.addHeaderCell("SPESE ESECUTIVE");
table.addCell("3.304,24");
table.addCell("0,00");
table.addCell("183,55");
table.addCell("8,75");
table.addCell("0,00");
canvas.add(table);
}
(RotateSomeContent test testForDropVid)
The result looks like this:
(I marked the rectangle area in yellow for illustration only.)
I would like two users to challenge each other to be able to use reactions so if you can only have one command to use.
Using the command tfo #user I would like you to send a private message to the user with the possibility of clicking one of the two reactions to accept or reject the challenge having a time limit that in case it is not executed in time cancels the challenge request and will send another private message (to both of you).
I know that to do this I should use await client.wait_for but I don't know how to use it for reactions.
This is the code I used for the version against the bot
#client.command(aliases=["TFO"])
async def tenta_la_fortuna_offline(ctx, amount : int):
id = str(ctx.message.author.id)
amounts[id] -= amount
if amounts[id] < 0:
await ctx.send(f"Non hai abbastanza soldi per giocare.")
amounts[id] += amount
return
if amount < 99:
await ctx.send("Puoi puntare da 100 in poi")
return
if not amount:
await ctx.send("Aggiungi quanti soldi vuoi puntare")
return
if id not in amounts:
await ctx.send("Hai bisogno di un account per giocare")
return
utente = [
('Sei salvo!', 'salvo',),
('Sei a rischio eliminazione!', 'rischio',),
('Sei __ELIMINATO__!', 'eliminato'),
('Hai __~~VINTO~~__!', 'vinto'),
('Sei a rischio eliminazione!', 'rischio',),
]
bot = [
('Sei salvo!', 'salvo',),
('Sei a rischio eliminazione!', 'rischio',),
('Sei __ELIMINATO__!', 'eliminato'),
('Hai __~~VINTO~~__!', 'vinto'),
('Sei a rischio eliminazione!', 'rischio',),
]
embed = discord.Embed(
title="**Tenta la Fortuna - Offline**",
description="Affronta il nostro bot per poter vincere il doppio dei soldi scommessi!",
color=0x003399
)
embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/640563710104043530/731596857868025886/TENTA_LA_FORTUNA.png')
embed.add_field(
name="**Utente**",
value="** **",
inline=True
)
embed.add_field(
name="**Bot**",
value="** **",
inline=True
)
message = await ctx.send(embed=embed)
win = int(amount * 2)
await asyncio.sleep(1)
for numero in range(1,101):
u_uscita, u_condizione = random.choice(utente)
embed.clear_fields()
if u_condizione == "eliminato":
embed = discord.Embed(
title="**Tenta la Fortuna - Offline**",
description="Affronta il nostro bot per poter vincere il doppio dei soldi scommessi!",
color=0xFF0000
)
embed.set_thumbnail(
url='https://cdn.discordapp.com/attachments/640563710104043530/731596857868025886/TENTA_LA_FORTUNA.png'
)
embed.set_footer(
text=f"Round numero {numero}"
)
embed.add_field(
name="**Utente**",
value=f"{u_uscita}",
inline=True
)
embed.add_field(
name="**Bot**",
value="** **",
inline=True
)
await message.edit(embed=embed)
return
if u_condizione == "vinto":
embed = discord.Embed(
title="**Tenta la Fortuna - Offline**",
description="Affronta il nostro bot per poter vincere il doppio dei soldi scommessi!",
color=0x00FF00
)
embed.set_thumbnail(
url='https://cdn.discordapp.com/attachments/640563710104043530/731596857868025886/TENTA_LA_FORTUNA.png'
)
embed.set_footer(
text=f"Round numero {numero}"
)
embed.add_field(
name="**Utente**",
value=f"{u_uscita}",
inline=True
)
embed.add_field(
name="**Bot**",
value="** **",
inline=True
)
await message.edit(embed=embed)
amounts[id] += win
return
embed.set_footer(
text=f"Round numero {numero}"
)
embed.add_field(
name="**Utente**",
value=f"{u_uscita}",
inline=True
)
embed.add_field(
name="**Bot**",
value="** **",
inline=True
)
await message.edit(embed=embed)
await asyncio.sleep(0.5)
b_uscita, b_condizione = random.choice(bot)
embed.clear_fields()
if b_condizione == "vinto":
embed = discord.Embed(
title="**Tenta la Fortuna - Offline**",
description="Affronta il nostro bot per poter vincere il doppio dei soldi scommessi!",
color=0xFF0000
)
embed.set_thumbnail(
url='https://cdn.discordapp.com/attachments/640563710104043530/731596857868025886/TENTA_LA_FORTUNA.png'
)
embed.set_footer(
text=f"Round numero {numero}"
)
embed.add_field(
name="**Utente**",
value=f"{u_uscita}",
inline=True
)
embed.add_field(
name="**Bot**",
value=f"{b_uscita}",
inline=True
)
await message.edit(embed=embed)
return
if u_condizione == "rischio":
if b_condizione == "salvo":
embed = discord.Embed(
title="**Tenta la Fortuna - Offline**",
description="Affronta il nostro bot per poter vincere il doppio dei soldi scommessi!",
color=0xFF0000
)
embed.set_thumbnail(
url='https://cdn.discordapp.com/attachments/640563710104043530/731596857868025886/TENTA_LA_FORTUNA.png'
)
embed.set_footer(
text=f"Round numero {numero}"
)
embed.add_field(
name="**Utente**",
value=f"{u_uscita}",
inline=True
)
embed.add_field(
name="**Bot**",
value=f"{b_uscita}",
inline=True
)
await message.edit(embed=embed)
return
if b_condizione == "eliminato":
embed = discord.Embed(
title="**Tenta la Fortuna - Offline**",
description="Affronta il nostro bot per poter vincere il doppio dei soldi scommessi!",
color=0x00FF00
)
embed.set_thumbnail(
url='https://cdn.discordapp.com/attachments/640563710104043530/731596857868025886/TENTA_LA_FORTUNA.png'
)
embed.set_footer(
text=f"Round numero {numero}"
)
embed.add_field(
name="**Utente**",
value=f"{u_uscita}",
inline=True
)
embed.add_field(
name="**Bot**",
value=f"{b_uscita}",
inline=True
)
await message.edit(embed=embed)
amounts[id] += amount
return
if b_condizione == "rischio":
if u_condizione == "salvo":
embed = discord.Embed(
title="**Tenta la Fortuna - Offline**",
description="Affronta il nostro bot per poter vincere il doppio dei soldi scommessi!",
color=0x00FF00
)
embed.set_thumbnail(
url='https://cdn.discordapp.com/attachments/640563710104043530/731596857868025886/TENTA_LA_FORTUNA.png'
)
embed.set_footer(
text=f"Round numero {numero}"
)
embed.add_field(
name="**Utente**",
value=f"{u_uscita}",
inline=True
)
embed.add_field(
name="**Bot**",
value=f"{b_uscita}",
inline=True
)
await message.edit(embed=embed)
amounts[id] += win
return
embed.set_footer(
text=f"Round numero {numero}"
)
embed.add_field(
name="**Utente**",
value=f"{u_uscita}",
inline=True
)
embed.add_field(
name="**Bot**",
value=f"{b_uscita}",
inline=True
)
await message.edit(embed=embed)
await asyncio.sleep(1)
if numero == 100:
embed = discord.Embed(
title="**Tenta la Fortuna - Offline**",
description="Affronta il nostro bot per poter vincere il doppio dei soldi scommessi!",
color=0xDBA901
)
embed.set_thumbnail(
url='https://cdn.discordapp.com/attachments/640563710104043530/731596857868025886/TENTA_LA_FORTUNA.png'
)
embed.set_footer(
text=f"Round numero {numero}"
)
embed.add_field(
name="**Utente**",
value=f"{u_uscita}",
inline=True
)
embed.add_field(
name="**Bot**",
value=f"{b_uscita}",
inline=True
)
await message.edit(embed=embed)
Your code fragment is huge & in another language so I can't help you directly (as I have no idea what's going on), but this is how to use wait_for with reactions:
#client.event
async def on_message(message):
if message.content.startswith('$thumb'):
channel = message.channel
await channel.send('Send me that 👍 reaction, mate')
def check(reaction, user):
return user == message.author and str(reaction.emoji) == '👍'
try:
reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check)
except asyncio.TimeoutError:
await channel.send('👎')
else:
await channel.send('👍')
Fragment taken out of the API Docs for wait_for, shows how to wait for a 👍 reaction & do something with it. In case the user doesn't add the reaction within the timeout (here 60 seconds), it will throw a TimeoutError and send 👎. You can modify this to fit your needs & put it in your command where it fits.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class enemyAI : MonoBehaviour
{
//Distance entre le joueur et le zombie
private float Distance;
// cible du zombie
public Transform Target;
//distance de poursuite
public float chaseRange = 10;
//portée des attaques
public float attackRange = 2.2f;
//Cooldown des attaques
public float attackRepeatTime = 1;
private float attackTime;
//Dégats infligés
public float TheDammage;
//Agent de navigation
private UnityEngine.AI.NavMeshAgent agent;
//Animation du zombie
private Animator animation;
void Start()
{
agent = gameObject.GetComponent<UnityEngine.AI.NavMeshAgent>();
animation = gameObject.GetComponent<Animator>();
attackTime = Time.time;
}
void Update()
{
//on cherche le joueur en permanence
Target = GameObject.Find("Player").transform;
//Calcul de la distance zombie player pour effectuée diverse action
Distance = Vector3.Distance(Target.position, transform.position);
//Quand player loin = idle
if (Distance > chaseRange)
{
idle();
}
//Quand zombien'est pas asser proche pour attaquer
if (Distance < chaseRange && Distance > attackRange)
{
chase();
}
//Quand zombie peut attaquer
if (Distance < attackRange)
{
Attack();
}
//poursuite
void chase()
{
animation.Play("walk");
agent.destination = Target.position;
}
//combat
void Attack()
{
// empêche le zombie de traverser le player
agent.destination = transform.position;
//si pas de cooldown
if (Time.time > attackTime)
{
animation.Play("Hit");
Target.GetComponent<PlayerInventory> ().ApplyDamage(TheDammage);
Debug.Log("Le zombie a frappé" + TheDammage + "point de dégats");
attackTime = Time.time + attackRepeatTime;
}
}
//idle
void idle()
{
animation.Play("idle");
}
}
}
I have errors on the unit about my code but I have no error on visual studio
Asset/enemyAI.cs(67,9):error CS1547:Keyword 'void' cannot be used in
this context
Asset/enemyAI.cs(67,18):error CS1525: Unexpected symbole '(',expecting
',','';' or'='
Asset/enemyAI.cs(93,0):error CS1525: Unexpected symbole '}'
I did not try anything because I really did not understand.
You aren't closing your Update function before beginning your chase function. Add another "}" after the end of your Update function to properly end that function before declaring new ones, like so:
...
//Quand zombie peut attaquer
if (Distance < attackRange)
{
Attack();
}
} //This properly ends your Update function
//Now we can declare the next function
//poursuite
void chase()
...
In general, if you properly maintain indentation in your files, these sorts of issues should be more obvious at a glance.
I have a function in my Controller that call my blade:
public function detalhe(Request $request){
//pega o ID da marcação
$id = $request['id'];
$marcacao = Marcacao::find($id);
//prepara a receita pra ser criada
$dadosReceita['marcacao_id'] = $id;
$dadosReceita['codigo'] = $marcacao->id . $marcacao->cidadao_id . $marcacao->agenda_id;
//consulta a receita
$receita = Receita::where('marcacao_id', $id)->first();
//verifica se existe a receita / cria a receita
if (count($receita) > 0){
$receitas_id = $receita['id'];
}else{
$receita = Receita::create($dadosReceita);
$receitas_id = $receita['id'];
}
//pega a lista dos produtos da receita
$produtoReceitas = ProdutoReceita::where('receitas_id', $receitas_id)->get();
//prepara o prontuario pra ser criado
$dadosProntuario['marcacao_id'] = $id;
//consulta o prontuario
$prontuario = Prontuario::where('marcacao_id', $id)->first();
//verifica se existe o prontuario / cria o prontuario
if (count($prontuario) > 0){
$prontuario_id = $prontuario['id'];
}else{
$prontuario = Prontuario::create($dadosProntuario);
$prontuario_id = $prontuario['id'];
}
//pega a lista dos ciaps do prontuario
$ciapProntuarios = CiapProntuario::where('prontuario_id', $prontuario_id)->get();
//pega a lista de produtos da undade
$produtos = ProdutoUnidade::where('unidade_id', 2)
->get();
$vencimento = new DateTime(date("y-m-d"));
$vencimento->add(new DateInterval('P90D'));
$vencimento = $vencimento->format('y-m-d');
$ciaps = Ciap::where('sexo', $marcacao->cidadao->sexo)
->orWhere('sexo', 'A')
->get();
return view('agendas.detalhe', compact('ciapsProntuario', 'marcacao', 'produtos', 'vencimento', 'ciaps', 'receitas_id', 'prontuario_id', 'produtoReceitas'));
}
This is very big. I have other function similar to the function above, but this have only three lines different.
I like to do the second function like below
public function two(){
//other lines differente
return detalhe(); //return my other function
}
When I put this code, I receive the error:
FatalErrorException
Call to undefined function App\Http\Controllers\detalhe()
You need to use $this.If it belongs to the same controller, call it using $this->detalhe(). Otherwise, use return redirect()->action('YourAction#YourController')
I'm having a little problem with my application while trying to use WindowsAPI...
I'm trying to connect to a handle in a way it works, but if I change the code it doesn't works anymore...
The code that works:
handle_t porta; // Global var
COMMTIMEOUTS tempos; // Global var
DCB configuracao; // Global var
wchar_t pcCommPort[]= TEXT("COM1");
//gate address to be accessed (COM1)
The code I'm trying to do:
handle_t porta; // Global var
COMMTIMEOUTS tempos; // Global var
DCB configuracao; // Global var
String GATE = "COM" + Label1->Text;
wchar_t pcCommPort[]= TEXT(GATE);
//gate address to be accessed (Any gate)
I've also tried it:
handle_t porta; // Global var
COMMTIMEOUTS tempos; // Global var
DCB configuracao; // Global var
wchar_t pcCommPort[]= TEXT("COM" + Label1->Text);
//gate address to be accessed (Any gate)
And it:
handle_t porta; // Global var
COMMTIMEOUTS tempos; // Global var
DCB configuracao; // Global var
String GATE = "COM" + Label1->Text;
wchar_t pcCommPort[]= GATE;
//gate address to be accessed (Any gate)
In any way or it says that I haven't mede the correct syntax or the error: Cannot convert unicode string into a wchar_t.
EDIT:
Full source (function):
void abrirporta(){
wchar_t pcCommPort[]= TEXT("COM1");
//endereço da porta a ser acessada (COM1)
//porta foi declarado como HANDLE na seção private da declaração de classe Form
//HANDLE porta
porta = CreateFile(pcCommPort,GENERIC_READ+GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
if(porta == INVALID_HANDLE_VALUE){
log(7);
throw Exception("Não foi possível abrir a porta COM.\nPor favor, tente novamente!");
}
//Tempo máximo entre o recebimento de 2 bytes (ms)
tempos.ReadIntervalTimeout = 20;
//Multiplicador de tempo de recebimento por byte
tempos.ReadTotalTimeoutMultiplier = 0;
tempos.ReadTotalTimeoutConstant = 100;
tempos.WriteTotalTimeoutMultiplier = 0;
tempos.WriteTotalTimeoutConstant = 100;
if(!SetCommTimeouts(porta ,&tempos))
{
CloseHandle(porta);
frmPrincipal->spLig->Visible = False;
frmPrincipal->spStatusInd->Visible = False;
log(6);
throw Exception("Erro na configuração de Timeout");
}
GetCommState(porta, &configuracao);
configuracao.BaudRate = 19200;
configuracao.ByteSize = 8;
configuracao.Parity = NOPARITY;
configuracao.StopBits = ONESTOPBIT;
if(!SetCommState(porta,&configuracao))
{
CloseHandle(porta);
frmPrincipal->spLig->Visible = False;
frmPrincipal->spStatusInd->Visible = False;
log(5);
throw Exception("Erro na Configuração da porta");
}
frmPrincipal->spLig->Visible = True;
frmPrincipal->spStatusInd->Visible = False;
log(3);
frmPrincipal->btEnviar->Enabled = true;
frmPrincipal->swSaida1->Enabled = true;
log(8);
}
I hope you can help me...
Since now thanks XD.
You are making this more difficult then it needs to be. System::String is an alias for System::UnicodeString, which holds wchar_t data on Windows. You don't need to copy the UnicodeString data into a wchar_t[] buffer. You can use the UnicodeString::c_str() method when you need to pass a String to a function that expects wchar_t* parameters, eg:
void abrirporta()
{
String pcCommPort = L"COM" + Label1->Text;
porta = CreateFile(pcCommPort.c_str(), ...);
...
}