小编Nev*_*ind的帖子

Android Studio Libgdx内存问题

我的应用程序有些问题.有时它会滞后并给我"GC_CONCURRENT释放".我使用MAT来查看消耗如此多内存的内容,并且我发现对象列表占用了大量内存.问题是我的游戏中有块,我需要看看我的玩家是否踩到它们,这就是我使用这个列表的原因.我目前有200块,但我会有更多,我不认为他们应该使用这么多内存,我该怎么办才能解决这个问题?这是块类的外观:

package com.NeverMind.DontFall.android;

import android.util.Log;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

/**
 * Created by user on 20-Aug-15.
 */
public class blockClass {
    private SpriteBatch spriteBatch;
    public float x, y, sizeX = 100, sizeY = 100, startTime;
    private boolean isTouched = false;
    private Texture texture;
    Sprite blockSprite;
    public blockClass(float sentX, float sentY, Texture sentTexture, float scaleX, float scaleY){
        x = sentX;
        y = sentY;
        sizeY *= scaleY;
        sizeX *= scaleX;
        spriteBatch = new SpriteBatch();
        texture = sentTexture;
        blockSprite …
Run Code Online (Sandbox Code Playgroud)

memory android libgdx

3
推荐指数
1
解决办法
168
查看次数

Haskell检查自定义数据类型是否均匀

所以我使用以下数据类型进行此练习

data Nat = Zero | Succ Nat deriving (Eq,Ord,Show,Read)
Run Code Online (Sandbox Code Playgroud)

这可以用于表示自然数,例如2 = Succ(Succ Zero).我实现了一个检查数字是否均匀的函数.

even :: Nat -> Bool
even x = count x `mod` 2 == 0

count :: Nat -> Int
count Zero = 0
count (Succ x) = 1 + count x
Run Code Online (Sandbox Code Playgroud)

它适用于零,但每当我尝试不同的东西,如计数Succ Zero或计数Succ(Succ Zero)

*Main> even Succ Zero

<interactive>:6:1: error:
    * Couldn't match expected type `Nat -> t' with actual type `Bool'
    * The function `evenN' is applied to two arguments,
      but its type `Nat -> …
Run Code Online (Sandbox Code Playgroud)

haskell types

1
推荐指数
1
解决办法
247
查看次数

C++17 为什么传入参数时没有提供默认构造函数

我有这门课:

\n
class MyClass {\npublic:\n    int someMember;\n    std::vector<int> someVectorMember;\n};\n
Run Code Online (Sandbox Code Playgroud)\n

我想知道为什么这行不通:

\n
MyClass(1, std::vector<int>{1,2});\n
Run Code Online (Sandbox Code Playgroud)\n

错误:

\n
main.cpp:21:37: error: no matching function for call to \xe2\x80\x98MyClass::MyClass(int, std::vector)\xe2\x80\x99\n
Run Code Online (Sandbox Code Playgroud)\n

c++ constructor initialization

1
推荐指数
1
解决办法
126
查看次数

Haskell类型的解释

我不明白以下代码的简单类型错误

addCustom :: Num a => a -> a
addCustom a = a + 1.2
Run Code Online (Sandbox Code Playgroud)

它抛出

无法推断(分数a)由字面"1.2"引起

我无法弄清楚为什么.

haskell types

0
推荐指数
1
解决办法
122
查看次数

Haskell表达式数据类型

我想在Haskell中拥有以下数据类型:

data Exp = Add Exp Exp
     | Var String 
     | Let (Var String) Exp Exp
     | Int Int 
Run Code Online (Sandbox Code Playgroud)

但是,不允许使用(Var String).我可以使用Exp代替(Var String),但我不希望在那里允许使用Int,所以我该如何解决这个问题呢?

haskell types

-1
推荐指数
1
解决办法
81
查看次数

标签 统计

haskell ×3

types ×3

android ×1

c++ ×1

constructor ×1

initialization ×1

libgdx ×1

memory ×1