Java 类com.badlogic.gdx.utils.GdxRuntimeException 实例源码

项目:Inspiration    文件:BehaviorTreeParser.java   
@Override
public void parse (char[] data, int offset, int length) {
    debug = btParser.debugLevel > BehaviorTreeParser.DEBUG_NONE;
    root = null;
    clear();
    super.parse(data, offset, length);

    // Pop all task from the stack and check their minimum number of children
    popAndCheckMinChildren(0);

    Subtree<E> rootTree = subtrees.get("");
    if (rootTree == null) throw new GdxRuntimeException("Missing root tree");
    root = rootTree.rootTask;
    if (root == null) throw new GdxRuntimeException("The tree must have at least the root task");

    clear();
}
项目:GDX-Engine    文件:DefaultGameAsset.java   
@Override
public ShaderProgram loadShader(String vsFilePath)
{
    if(!Game.isSupportOpenGL20)
        return null;

    String fsProcess = vsFilePath.substring(0, vsFilePath.length()-7);
    fsProcess += "fs.glsl";
    ShaderProgram shader = new ShaderProgram(Gdx.files.internal(vsFilePath),
            Gdx.files.internal(fsProcess));

    if(shader.isCompiled())
        return shader;
    else
        throw new GdxRuntimeException("Cannot compile the shader");
}
项目:GDX-Engine    文件:AnimatedSprite.java   
public void PlayAnimation(Animation animation, Rectangle newRegionOnTexture)
  {
if (animation == null && this.animation == null)
          throw new GdxRuntimeException("No animation is currently playing.");
      // If this animation is already running, do not restart it.
      if (this.animation == animation)
          return;

      // Start the new animation.
      this.animation = animation;
      this.frameIndex = 0;
      this.animationTimeline = 0.0f;

      this.setRegionX((int) newRegionOnTexture.x);
      this.setRegionY((int) newRegionOnTexture.y);
      this.setRegionWidth((int) newRegionOnTexture.getWidth());
      this.setRegionHeight((int) newRegionOnTexture.getHeight());
      onAnimationChanged();
  }
项目:GDX-Engine    文件:PhysicsManager.java   
public Body createTempBody(float x, float y, FixtureDef fixtureDef) {
// Dynamic Body
BodyDef bodyDef = new BodyDef();
if (box2dDebug)
    bodyDef.type = BodyType.StaticBody;
else
    bodyDef.type = BodyType.DynamicBody;

// transform into box2d
x = x * WORLD_TO_BOX;
y = y * WORLD_TO_BOX;

bodyDef.position.set(x, y);

Body body = world.createBody(bodyDef);

Shape shape = new CircleShape();
((CircleShape) shape).setRadius(1 * WORLD_TO_BOX);

if (fixtureDef == null)
    throw new GdxRuntimeException("fixtureDef cannot be null!");
fixtureDef.shape = shape;
body.createFixture(fixtureDef);
return body;
   }
项目:GDX-Engine    文件:AnimationPlayer.java   
public void PlayAnimation(Sprite sprite, Animation animation,
    Rectangle newRegionOnTexture) {
if (animation == null && this.animation == null)
    throw new GdxRuntimeException("No animation is currently playing.");
// If this animation is already running, do not restart it.
if (this.animation == animation)
    return;

// Start the new animation.
this.animation = animation;
this.frameIndex = 0;
this.animationTimeline = 0.0f;

sprite.setRegionX((int) newRegionOnTexture.x);
sprite.setRegionY((int) newRegionOnTexture.y);
sprite.setRegionWidth((int) newRegionOnTexture.getWidth());
sprite.setRegionHeight((int) newRegionOnTexture.getHeight());
onAnimationChanged();
   }
项目:GDX-Engine    文件:PhysicsTiledScene.java   
public Body createTempBody(float x, float y, FixtureDef fixtureDef) {
    // Dynamic Body
    BodyDef bodyDef = new BodyDef();
    if (box2dDebug)
        bodyDef.type = BodyType.StaticBody;
    else
        bodyDef.type = BodyType.DynamicBody;

    // transform into box2d
    x = x * WORLD_TO_BOX;
    y = y * WORLD_TO_BOX;

    bodyDef.position.set(x, y);

    Body body = world.createBody(bodyDef);

    Shape shape = new CircleShape();
    ((CircleShape) shape).setRadius(1 * WORLD_TO_BOX);

    if (fixtureDef == null)
        throw new GdxRuntimeException("fixtureDef cannot be null!");
    fixtureDef.shape = shape;
    body.createFixture(fixtureDef);
    return body;
}
项目:GDX-Engine    文件:BaseGameScene3D.java   
/**
 * Call right before starting render stage of Scene 3D
 */
protected void preRender() {
    //Create default member for managers if the managers don't have any member. 
    if(camera.count() == 0)
    {
        camera.add("default", new FreeCamera(70, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), new Vector3(0, 5, 5), 0,135));
        camera.setActiveCamera("default");
    }
    if(light.count() == 0 && Game.isSupportOpenGL20)
    {
        light.addBaseLight("default", new DirectionLight(new Vector3(1, 1, 1), new Vector3(1, 1, -1)));
    }
    if(shader.count() == 0 && Game.isSupportOpenGL20)
    {
        String vs = loadShaderFile("effect/default-vs.glsl");
        String fs = loadShaderFile("effect/default-fs.glsl");
        ShaderProgram s = new ShaderProgram(vs , fs);
        if(!s.isCompiled())
        {
            throw new GdxRuntimeException("Cannot compile default shader");
        }
        shader.add("default", s);
        shader.setActiveShader("default");
    }
}
项目:Cubes_2    文件:MultiplayerLoadingMenu.java   
@Override
public void render() {
    super.render();
    frameNum++;
    if (frameNum != 2)
        return;
    try {
        NetworkingManager.clientPreInit(new ClientNetworkingParameter(address, port));
        CubesClient cubesClient = new CubesClient();
        Adapter.setServer(null);
        Adapter.setClient(cubesClient);
        Adapter.setMenu(new WorldLoadingMenu());
    } catch (Exception e) {
        if (e instanceof GdxRuntimeException && e.getCause() instanceof Exception)
            e = (Exception) e.getCause();
        Adapter.setClient(null);
        Log.error("Failed to connect", e);
        Log.error("Address:" + address + " Port:" + port);
        Adapter.setMenu(new ConnectionFailedMenu(e));
        Adapter.setClient(null);
        Adapter.setServer(null);
    }
}
项目:KyperBox    文件:KyperMapLoader.java   
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle tmxFile,
        com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader.AtlasTiledMapLoaderParameters parameter) {
    Array<AssetDescriptor> dependencies = new Array<AssetDescriptor>();
    try {
        root = xml.parse(tmxFile);

        Element properties = root.getChildByName("properties");
        if (properties != null) {
            for (Element property : properties.getChildrenByName("property")) {
                String name = property.getAttribute("name");
                String value = property.getAttribute("value");
                if (name.startsWith("atlas")) {
                    FileHandle atlasHandle = Gdx.files.internal(value);
                    dependencies.add(new AssetDescriptor(atlasHandle, TextureAtlas.class));
                }
            }
        }
    } catch (IOException e) {
        throw new GdxRuntimeException("Unable to parse .tmx file.");
    }
    return dependencies;
}
项目:KyperBox    文件:KyperMapLoader.java   
@Override
public void loadAsync(AssetManager manager, String fileName, FileHandle tmxFile,
        com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader.AtlasTiledMapLoaderParameters parameter) {
    map = null;
    if (parameter != null) {
        convertObjectToTileSpace = parameter.convertObjectToTileSpace;
        flipY = parameter.flipY;
    } else {
        convertObjectToTileSpace = false;
        flipY = true;
    }

    try {
        map = loadMap(root, tmxFile, new AtlasResolver.AssetManagerAtlasResolver(manager));
    } catch (Exception e) {
        throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e);
    }
}
项目:KyperBox    文件:TiledObjectTypes.java   
public TiledObjectTypes(String file) {
    xml_reader = new XmlReader();
    try {
        root = xml_reader.parse(Gdx.files.internal(file));
    } catch (IOException e) {
        e.printStackTrace();
    }
    types = new ObjectMap<String, TiledObjectTypes.TiledObjectType>();

    if(root == null)
        throw new GdxRuntimeException(String.format("Unable to parse file %s. make sure it is the correct path.", file));
    Array<Element> types = root.getChildrenByName("objecttype");
    for (Element element : types) {
        TiledObjectType tot = new TiledObjectType(element.get("name"));
        Array<Element> properties  = element.getChildrenByName("property");
        for (int i = 0; i < properties.size; i++) {
            Element element2 = properties.get(i);
            TypeProperty property = new TypeProperty(element2.get("name"), element2.get("type"), element2.hasAttribute("default")?element2.get("default"):"");
            tot.addProperty(property);
        }
        this.types.put(tot.name, tot);
    }

}
项目:Cubes    文件:MultiplayerLoadingMenu.java   
@Override
public void render() {
  super.render();
  frameNum++;
  if (frameNum != 2) return;
  try {
    NetworkingManager.clientPreInit(new ClientNetworkingParameter(address, port));
    CubesClient cubesClient = new CubesClient();
    Adapter.setServer(null);
    Adapter.setClient(cubesClient);
    Adapter.setMenu(new WorldLoadingMenu());
  } catch (Exception e) {
    if (e instanceof GdxRuntimeException && e.getCause() instanceof Exception) e = (Exception) e.getCause();
    Adapter.setClient(null);
    Log.error("Failed to connect", e);
    Log.error("Address:" + address + " Port:" + port);
    Adapter.setMenu(new ConnectionFailedMenu(e));
    Adapter.setClient(null);
    Adapter.setServer(null);
  }
}
项目:fabulae    文件:ItemOwner.java   
private String getOwnerCharacterName() {
    if (ownerCharacterName == null && s_ownerCharacterId != null) {
        try {
            GameObject go = GameState.getGameObjectById(s_ownerCharacterId);
            if (go instanceof GameCharacter) {
                ownerCharacterName =  ((GameCharacter) go).getName();
            } else {
                XmlReader xmlReader = new XmlReader();
                Element root = xmlReader.parse(Gdx.files
                        .internal(Configuration.getFolderCharacters()
                                + s_ownerCharacterId + ".xml"));
                ownerCharacterName = root.getChildByName(
                        XMLUtil.XML_PROPERTIES).get(
                        XMLUtil.XML_ATTRIBUTE_NAME);
            }
        } catch (SerializationException e) {
            throw new GdxRuntimeException("Could not determine the owner with type "+s_ownerCharacterId, e);
        }
        if (ownerCharacterName == null) {
            throw new GdxRuntimeException("Could not determine the owner with type "+s_ownerCharacterId);
        }
    }
    return Strings.getString(ownerCharacterName);
}
项目:gdx-bullet-gwt    文件:btIndexedMesh.java   
/** Create or reuse a btIndexedMesh instance based on the specified tag.
 * Use {@link #release()} to release the mesh when it's no longer needed. */
public static btIndexedMesh obtain(final Object tag,
        final FloatBuffer vertices, int sizeInBytesOfEachVertex, int vertexCount, int positionOffsetInBytes,
        final ShortBuffer indices, int indexOffset, int indexCount) {
    if (tag == null)
        throw new GdxRuntimeException("tag cannot be null");

    btIndexedMesh result = getInstance(tag);
    if (result == null) {
        result = new btIndexedMesh(vertices, sizeInBytesOfEachVertex, vertexCount, positionOffsetInBytes, indices, indexOffset, indexCount);
        result.tag = tag;
        instances.add(result);
    }
    result.obtain();
    return result;
}
项目:Planetbase    文件:ImmutableArrayTests.java   
@Test
public void forbiddenRemoval () {
    Array<Integer> array = new Array<Integer>();
    ImmutableArray<Integer> immutable = new ImmutableArray<Integer>(array);

    for (int i = 0; i < 10; ++i) {
        array.add(i);
    }

    boolean thrown = false;

    try {
        immutable.iterator().remove();
    } catch (GdxRuntimeException e) {
        thrown = true;
    }

    assertEquals(true, thrown);
}
项目:fabulae    文件:XMLUtil.java   
/**
 * Read the actions from the suppled XML element and loads them into the
 * supplied ActionsContainer.
 * 
 * The XML element should contain children in the following format:
 * 
 * <pre>
 * &lt;actionClassName parameter1Name="parameter1Value" parameter2Name="parameter2Value" ... /&gt;
 * </pre>
 * 
 * @param ac
 * @param actionsElement
 */
@SuppressWarnings({ "unchecked" })
public static void readActions(ActionsContainer ac, Element actionsElement) {
    if (actionsElement != null) {
        for (int i = 0; i < actionsElement.getChildCount(); ++i) {
            Element actionElement = actionsElement.getChild(i);
            String implementationClassName = actionElement.getName();
            implementationClassName = Action.class.getPackage().getName() + "."
                    + StringUtil.capitalizeFirstLetter(implementationClassName);
            try {
                Class<? extends Action> actionClass = (Class<? extends Action>) ClassReflection
                        .forName(implementationClassName);
                Action newAction = ac.addAction(actionClass);
                if (newAction != null) {
                    newAction.loadFromXML(actionElement);
                }

            } catch (ReflectionException e) {
                throw new GdxRuntimeException(e);
            }
        }
    }
}
项目:Undertailor    文件:OggInputStream.java   
/** Create a new stream to decode OGG data, reusing buffers from another stream.
 *
 * It's not a good idea to use the old stream instance afterwards.
 *
 * @param input The input stream from which to read the OGG file
 * @param previousStream The stream instance to reuse buffers from, may be null */
OggInputStream (InputStream input, OggInputStream previousStream) {
    if (previousStream == null) {
        convbuffer = new byte[convsize];
        pcmBuffer = BufferUtils.createByteBuffer(4096 * 500);
    } else {
        convbuffer = previousStream.convbuffer;
        pcmBuffer = previousStream.pcmBuffer;
    }

    this.input = input;
    try {
        total = input.available();
    } catch (IOException ex) {
        throw new GdxRuntimeException(ex);
    }

    init();
}
项目:fabulae    文件:Effect.java   
/**
 * Executes the duration script of this effect, which will determine the duration
 * of any persistent effects this effect has. The duration is in turns, which can be
 * translated to seconds by using {@link Configuration#getCombatTurnDurationInGameSeconds()}.
 * 
 * @param context
 * @return
 */
private Float getDuration(Binding context) {
    if (durationScript == null) {
        return 0f;
    }

    durationScript.setBinding(context);
    Object returnValue = durationScript.run();
    if (returnValue == null) {
        return 0f;
    }
    if (returnValue instanceof Float) {
        return (Float) returnValue;
    }
    if (returnValue instanceof Integer) {
        return ((Integer)returnValue).floatValue();
    }
    if (returnValue instanceof String) {
        try {
            return Float.parseFloat((String)returnValue);
        } catch (NumberFormatException e) {
            throw new GdxRuntimeException(e);
        }
    }
    throw new GdxRuntimeException("Could not determine effect duration for effect "+getId()+", duration script is not empty but did not return a number.");
}
项目:nhglib    文件:NhgFloatTextureData.java   
@Override
public void consumeCustomData(int target) {
    if (Gdx.app.getType() == Application.ApplicationType.Android || Gdx.app.getType() == Application.ApplicationType.iOS
            || Gdx.app.getType() == Application.ApplicationType.WebGL) {

        if (!Gdx.graphics.supportsExtension("OES_texture_float"))
            throw new GdxRuntimeException("Extension OES_texture_float not supported!");

        // GLES and WebGL defines texture format by 3rd and 8th argument,
        // so to get a float texture one needs to supply GL_RGBA and GL_FLOAT there.
        Gdx.gl.glTexImage2D(target, 0, internalFormat, width, height, 0, format, GL20.GL_FLOAT, buffer);
    } else {
        if (!Gdx.graphics.supportsExtension("GL_ARB_texture_float"))
            throw new GdxRuntimeException("Extension GL_ARB_texture_float not supported!");

        // in desktop OpenGL the texture format is defined only by the third argument,
        // hence we need to use GL_RGBA32F there (this constant is unavailable in GLES/WebGL)
        Gdx.gl.glTexImage2D(target, 0, internalFormat, width, height, 0, format, GL20.GL_FLOAT, buffer);
    }
}
项目:fabulae    文件:Configuration.java   
private Configuration(final Files files, final String moduleName) {
    if (configuration != null) {
        this.options = configuration.options;
    } else {
        loadOptions(files);
    }
    configuration = this;
    this.moduleName = moduleName;
    this.moduleFolder = FOLDER_MODULES + moduleName + "/";
    String file = moduleFolder + "config.xml";
    try {
        loadFromXML(files.internal(file));
        loadingScreensConfiguration = new LoadingScreens(files.internal(Configuration.getFolderUI()
                + "loadingScreens.xml"));
    } catch (final IOException e) {
        throw new GdxRuntimeException("Cannot read configuration file " + file + ", aborting.", e);
    }
}
项目:libgdx-jbullet    文件:MatrixUtil.java   
public static void getColumn (Matrix3 src, int col, Vector3 v) {
    if (col == 0) {
        v.x = src.val[Matrix3.M00];
        v.y = src.val[Matrix3.M10];
        v.z = src.val[Matrix3.M20];
    } else if (col == 1) {
        v.x = src.val[Matrix3.M01];
        v.y = src.val[Matrix3.M11];
        v.z = src.val[Matrix3.M21];
    } else if (col == 2) {
        v.x = src.val[Matrix3.M02];
        v.y = src.val[Matrix3.M12];
        v.z = src.val[Matrix3.M22];
    } else {
        throw new GdxRuntimeException("Invalid column");
    }
}
项目:fabulae    文件:StateMachine.java   
@Override
public void loadFromXML(Element root) throws IOException {
    XMLUtil.readPrimitiveMembers(this, root);
    readStates(root);
    s_startState = s_startState.toLowerCase(Locale.ENGLISH);
    endStates = new Array<String>();

    if (s_endState != null) {
        String[] endStatesSplit = s_endState.toLowerCase(Locale.ENGLISH).trim().split(",");
        for (String state : endStatesSplit) {
            endStates.add(state.trim());
        }
    }

    if (s_startState == null) {
        throw new GdxRuntimeException("Start state must be defined in state machine "+getId());
    }
    if (endStates.contains(s_startState, false)) {
        throw new GdxRuntimeException("Start state and end state must be different in state machine "+getId());
    }
}
项目:fabulae    文件:ProjectileTypeLoader.java   
@SuppressWarnings("rawtypes")
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, ProjectileTypeParameter parameter) {
    XmlReader xmlReader = new XmlReader();
    try {
        Array<AssetDescriptor>  returnValue = new Array<AssetDescriptor>();
        Element root = xmlReader.parse(file);
        LoaderUtil.handleImports(this, parameter, returnValue, file, root);
        String animationFile = root.get(ProjectileType.XML_ANIMATION_FILE, null);
        if (animationFile != null) {
            returnValue.add(new AssetDescriptor<Texture>(Configuration.addModulePath(animationFile), Texture.class));
        }
        Element soundsElement = root.getChildByName(XMLUtil.XML_SOUNDS);
        if (soundsElement != null) {
            addSoundDependency(soundsElement, ProjectileType.XML_ON_START, returnValue);
            addSoundDependency(soundsElement, ProjectileType.XML_ON_HIT, returnValue);
            addSoundDependency(soundsElement, ProjectileType.XML_DURING, returnValue);
        }
        if (returnValue.size > 0) {
            return returnValue;
        }
    } catch (IOException e) {
        throw new GdxRuntimeException(e);
    }
    return null;
}
项目:fabulae    文件:CharacterInParty.java   
@Override
protected Object[] getStringNameParams() {
    try {
        String id = getParameter(XML_CHARACTER_ID);
        String name = null;
        if (id != null) {
            GameObject go = GameState.getGameObjectById(id);
            if (go == null) {
                // if the character has not been loaded yet, load it now,
                // get the name and dispose of it
                // this will probably incur a performance hit
                go = GameCharacter.loadCharacter(id);
                name = go.getName();
                go.remove();
            } else {
                name = go.getName();
            }
        } else {
            // TODO: this is not great, these should be localized, but this is a terrible edge case, so maybe later (yeah, right...)
            name = getParameter(PARAM_TARGET_OBJECT);
        }
        return new Object[]{name};
    } catch (IOException e) {
        throw new GdxRuntimeException(e);
    }
}
项目:fabulae    文件:UseInventoryItemAction.java   
@Override
public void init(ActionsContainer ac, Object... parameters) {
    if (!(ac instanceof GameCharacter)) {
        throw new GdxRuntimeException("UseInventoryItemAction only works on GameCharacter!");
    }
    itemId = null;
    usable = null;
    effectTarget = null;
    itemUseInProgress = false;
    moveToInitiated = false;
    user = (GameCharacter) ac;
    isFinished = false;
    if (parameters.length >= 2) {
        usable = (UsableItem) parameters[0];
        itemId = usable.getId();
        effectTarget = (TargetType) parameters[1];
    }
    // if the item can be used instantly, just do it right now
    if (canBeUsedInstantly()) {
        update(0);
        isFinished = true;
    }
}
项目:exterminate    文件:LwjglGraphics.java   
@Override
public DisplayMode[] getDisplayModes () {
    try {
        org.lwjgl.opengl.DisplayMode[] availableDisplayModes = Display.getAvailableDisplayModes();
        DisplayMode[] modes = new DisplayMode[availableDisplayModes.length];

        int idx = 0;
        for (org.lwjgl.opengl.DisplayMode mode : availableDisplayModes) {
            if (mode.isFullscreenCapable()) {
                modes[idx++] = new LwjglDisplayMode(mode.getWidth(), mode.getHeight(), mode.getFrequency(),
                    mode.getBitsPerPixel(), mode);
            }
        }

        return modes;
    } catch (LWJGLException e) {
        throw new GdxRuntimeException("Couldn't fetch available display modes", e);
    }
}
项目:fabulae    文件:TrapLoader.java   
@SuppressWarnings("rawtypes")
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, TrapParameter parameter) {
    XmlReader xmlReader = new XmlReader();
    try {
        Array<AssetDescriptor>  returnValue = new Array<AssetDescriptor>();
        Element root = xmlReader.parse(file);
        LoaderUtil.handleImports(this, parameter, returnValue, file, root);
        Element soundsElement = root.getChildByName(XMLUtil.XML_SOUNDS);
        if (soundsElement != null) {
            addSoundDependency(soundsElement, TrapType.XML_DISARMED, returnValue);
            addSoundDependency(soundsElement, TrapType.XML_SPRUNG, returnValue);
        }
        if (returnValue.size > 0) {
            return returnValue;
        }
    } catch (IOException e) {
        throw new GdxRuntimeException(e);
    }
    return null;
}
项目:fabulae    文件:LoaderUtil.java   
public static <T, P extends AssetLoaderParameters<T>> void handleImports(
        AssetLoader<T, P> loader, P parameter,
        @SuppressWarnings("rawtypes") Array<AssetDescriptor> dependencies, FileHandle parentFile,
        Element root) throws IOException {
    Array<Element> imports = root.getChildrenByName(XMLUtil.XML_IMPORT);
    for (Element singleImport : imports) {
        String filename = singleImport.get(XMLUtil.XML_FILENAME);
        FileHandle file = parentFile.parent().child(filename);
        if (!file.exists()) {
            throw new GdxRuntimeException("Import " + file.path()
                    + " from import for " + parentFile.name()
                    + " does not exist.");
        }
        dependencies.addAll(loader.getDependencies(filename, file, parameter));
    }
}
项目:fabulae    文件:FireQuestEvent.java   
@Override
protected void run(Object object, Binding parameters) {
    Quest quest = null;
    if (object instanceof Quest) {
        quest = (Quest) object;
    }

    String questId = getParameter(XML_QUEST);
    if (questId != null) {
        quest = Quest.getQuest(questId);
    }

    if (quest == null) {
        throw new GdxRuntimeException("Could not find quest with id "+questId+" for action "+getClass().getName());
    }

    quest.processEvent(getParameter(XML_EVENT));
}
项目:beatoraja    文件:VLCMovieProcessor.java   
@Override
        public void onDisplay(DirectMediaPlayer mediaPlayer, int[] data) {
            if (size != data.length) {
                byteBuffer = ByteBuffer.allocateDirect(data.length * 4).order(ByteOrder.nativeOrder());
                size = data.length;
            }
            IntBuffer intBuffer = byteBuffer.asIntBuffer();
            intBuffer.put(data);

            try {
                Gdx2DPixmap pixmapData = new Gdx2DPixmap(byteBuffer, nativeData);
                pixmap = new Pixmap(pixmapData);
//              System.out.println("movie pixmap created : " + mediaPlayer.getTime() + " / " + mediaPlayer.getLength()
//                      + "   data size : " + data.length * 4);
            } catch (Exception e) {
                pixmap = null;
                throw new GdxRuntimeException("Couldn't load pixmap from image data", e);
            }

        }
项目:fabulae    文件:TweenToAction.java   
@Override
public void init(ActionsContainer ac, Object... parameters) {
    if (!(ac instanceof PositionedThing)) {
        throw new GdxRuntimeException("TweenToAction only works on PositionedThing!");
    }
    this.ac = ac;
    this.pt = (PositionedThing)ac;
    tweenFinished = false;
    tweenStarted = false;
    targetX = (Float) parameters[0];
    targetY = (Float) parameters[1];
    speed = (Float) parameters[2];
    delay = 0;
    tween = null;
    if (parameters.length > 3) {
        delay = (Float) parameters[3];
    }
}
项目:fabulae    文件:LockpickAction.java   
@Override
public void init(ActionsContainer ac, Object... parameters) {
    if (!(ac instanceof GameCharacter)) {
        throw new GdxRuntimeException("LockpickAction only works on GameCharacter!");
    }
    targetX = -1;
    targetY = -1;
    character = (GameCharacter) ac;
    if (parameters.length > 0) {
        this.lockable = (Lockable)parameters[0];
        this.targetX = lockable.position().getX();
        this.targetY = lockable.position().getY();
        super.init(ac, lockable.findSafeDisarmPath(new Path(), character, character.getMap().getPathFinder(), this.getClass()));

    }
}
项目:fabulae    文件:WeatherProfileLoader.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, WeatherProfileParameter parameter) {
    Array<AssetDescriptor> returnValue = new Array<AssetDescriptor>();
    try {
        XmlReader xmlReader = new XmlReader();
        Element root = xmlReader.parse(file);
        LoaderUtil.handleImports(this, parameter, returnValue, file, root);
        Array<Element> trackElements = root.getChildrenByNameRecursively(WeatherProfile.XML_TRACK);
        for (Element trackElement : trackElements) {
            String trackFileName = Configuration.addModulePath(trackElement.get(XMLUtil.XML_ATTRIBUTE_FILENAME));
            returnValue.add(new AssetDescriptor(trackFileName, WeatherProfile.XML_CONTINOUS.equalsIgnoreCase(trackElement.getParent().getName()) ? Music.class : Sound.class)); 
        }
    } catch (IOException e) {
        throw new GdxRuntimeException(e);
    }

    return returnValue;
}
项目:fabulae    文件:WanderAction.java   
@Override
public void init(ActionsContainer ac, Object... parameters) {
    if (!(ac instanceof AbstractGameCharacter)) {
        throw new GdxRuntimeException("WanderAction only works on AbstractGameCharacter!");
    }
    this.character = (AbstractGameCharacter)ac;
    // we will mark center coordinates as uninitialized, since the supplied character
    // might not have been fully initialized itself - we will init the coords in the update
    // method, since by then everything should be set
    this.centerX = -1;
    this.centerY = -1;
    reset();
    duration = DURATION_INFINITE;
    if (parameters.length > 1) { 
        this.radius = (Integer) parameters[0];
        this.chanceToMove = (Integer) parameters[1];
        if (parameters.length > 2) {
            this.duration = (Integer) parameters[2];
        }
        if (parameters.length > 3) {
            this.visibleOnly = (Boolean) parameters[3];
        }
    }
}
项目:fabulae    文件:LookAtAction.java   
@Override
public void init(ActionsContainer ac, Object... parameters) {
    if (!(ac instanceof GameObject) || !(ac instanceof OrientedThing)) {
        throw new GdxRuntimeException("LookAtAction only works on GameObjects implementing OrientedThing!");
    }
    isFinished = false;
    this.go = (GameObject) ac;
    if (parameters.length == 1) { 
        PositionedThing target = (PositionedThing) parameters[0];
        targetX = target.position().getX();
        targetY = target.position().getY();
    } else if  (parameters.length == 2) { 
        targetX = (Float)parameters[0];
        targetY = (Float)parameters[1];
    } 
}
项目:cocos2d-java    文件:NodeType.java   
/**
 * 获取该type对应的node实例 <p>
 * 
 * 调用node.pushBack() 归还对象
 * @return Node */
public final Node getInstance() {
    Node a = factory.getObject(this);
    if(a == null) {
        throw new GdxRuntimeException("getInstance fail: " + this);
    }
    return a;
}
项目:cocos2d-java    文件:BhTreeLoader.java   
final StructBHTNode parseBHTNode(int depth, JsonValue jv) {
    String name = jv.name;
    String args = jv.getString("args", null);
    String key = jv.getString("key", null);
    StructBHTNode BHTNode = new StructBHTNode();
    BHTNode.type = name;
    BHTNode.args = args;
    BHTNode.key = key;
    BHTNode.depth = depth;

    int childrenCount = jv.size;
    if(args != null) {
        childrenCount -= 1;
    }
    if(key != null) {
        childrenCount -= 1;
    }
    if(childrenCount > 0) {
        BHTNode.children = new StructBHTNode[childrenCount];
    }

    for(int i = 0, count = 0; i < jv.size; ++i) {
        JsonValue jv_child = jv.get(i);
        if(jv_child.name == null) {
            CCLog.error(TAG, "child name cannot be null!");
            throw new GdxRuntimeException("child name cannot be null!");
        }
        if(jv_child.name.equals("args") || jv_child.name.equals("key")) {
            continue;
        }

        BHTNode.children[count++] = parseBHTNode(depth+1, jv_child);
    }
    return BHTNode;
}
项目:gdx-gamesvcs    文件:GpgsClient.java   
private File findFileByNameSync(String name) throws IOException {
    // escape some chars (') see : https://developers.google.com/drive/v3/web/search-parameters#fn1
    List<File> files = GApiGateway.drive.files().list().setSpaces("appDataFolder").setQ("name='" + name + "'")
            .execute().getFiles();
    if (files.size() > 1) {
        throw new GdxRuntimeException("multiple files with name " + name + " exists.");
    } else if (files.size() < 1) {
        return null;
    } else {
        return files.get(0);
    }
}
项目:GDX-Engine    文件:AssetLoader.java   
@SuppressWarnings("unchecked")
public static <T> T load(String filepath,
        Object... parameters) {

    if(AssetLoader.type == null){
        throw new GdxRuntimeException("setAssetClass() must be called before you call this method");
    }

    return AssetLoader.<T>load(AssetLoader.type, filepath, parameters);
}
项目:GDX-Engine    文件:CameraManager.java   
/**
 * Add camera to collection collection of CameraManager
 * @param camera Camera to Add
 * @param key Key (ID) of camera
 */
public void addCamera(String key, Camera camera)
{
    if(collection.containsKey(key))
        throw new GdxRuntimeException("Camera key is existing in CameraManager!");

    collection.put(key, camera);
}