我在Lua制作一个游戏,需要多次改变图像.我现在这样做的方式是在旧图像上显示新图像.这可行,但它会导致很多延迟.我想知道是否有人知道摆脱旧图像然后将新图像放在同一位置的方法.多谢你们.
每次发生事情时我正在做的事情的例子:
local function checkPlayer1()
if P1 == 1 then
player1 = display.newImage("1.png",64,128) --starting
end
if P1 == 2 then
player1 = display.newImage("2.png",64,128)
end
if P1 == 3 then
player1 = display.newImage("3.png",64,128)
end
if P1 == 4 then
player1 = display.newImage("4.png",64,128)
end
if P1 == 5 then
player1 = display.newImage("5.png",64,128) --dead
end
end
Run Code Online (Sandbox Code Playgroud) 我有四舍五入的问题.出于某种原因,我不能testP到第十名.例如,在第一个给定的例子(Alex Smith)上,它给出了82.0的答案,但它应该是82.6.
以下是具有示例的作业:http://www.hpcodewars.org/past/cw5/problems/Average.htm
import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.math.*;
import java.util.Scanner;
public class Average {
public static void main(String[] args) {
int num = 0, temp =0;;
String fileName="AverageInput.txt";
String fileName2="AverageOutput.txt";
Scanner inputStream = null;
PrintWriter outputStream = null;
double homeworkP = 0;
//read
try{
inputStream = new Scanner(new File(fileName)); //try to open the file
}
catch(Exception e){
System.out.println("Could not open the file named "+ fileName); // if it doesn't find it, tell …Run Code Online (Sandbox Code Playgroud)