当前位置: 首页>>代码示例>>C++>>正文


C++ SpriteCache::findFreeSlot方法代码示例

本文整理汇总了C++中SpriteCache::findFreeSlot方法的典型用法代码示例。如果您正苦于以下问题:C++ SpriteCache::findFreeSlot方法的具体用法?C++ SpriteCache::findFreeSlot怎么用?C++ SpriteCache::findFreeSlot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpriteCache的用法示例。


在下文中一共展示了SpriteCache::findFreeSlot方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DynamicSprite_CreateFromDrawingSurface

ScriptDynamicSprite* DynamicSprite_CreateFromDrawingSurface(ScriptDrawingSurface *sds, int x, int y, int width, int height) 
{
    int gotSlot = spriteset.findFreeSlot();
    if (gotSlot <= 0)
        return NULL;

    // use DrawingSurface resolution
    sds->MultiplyCoordinates(&x, &y);
    sds->MultiplyCoordinates(&width, &height);

    Bitmap *ds = sds->StartDrawing();

    if ((x < 0) || (y < 0) || (x + width > ds->GetWidth()) || (y + height > ds->GetHeight()))
        quit("!DynamicSprite.CreateFromDrawingSurface: requested area is outside the surface");

    int colDepth = ds->GetColorDepth();

    Bitmap *newPic = BitmapHelper::CreateBitmap(width, height, colDepth);
    if (newPic == NULL)
        return NULL;

    newPic->Blit(ds, x, y, 0, 0, width, height);

    sds->FinishedDrawingReadOnly();

    add_dynamic_sprite(gotSlot, newPic, (sds->hasAlphaChannel != 0));
    ScriptDynamicSprite *new_spr = new ScriptDynamicSprite(gotSlot);
    return new_spr;
}
开发者ID:AlanDrake,项目名称:ags,代码行数:29,代码来源:dynamicsprite.cpp

示例2: DynamicSprite_CreateFromScreenShot

ScriptDynamicSprite* DynamicSprite_CreateFromScreenShot(int width, int height) {

    int gotSlot = spriteset.findFreeSlot();
    if (gotSlot <= 0)
        return NULL;

    if (width <= 0)
        width = virtual_screen->GetWidth();
    else
        width = multiply_up_coordinate(width);

    if (height <= 0)
        height = virtual_screen->GetHeight();
    else
        height = multiply_up_coordinate(height);

    Bitmap *newPic;
    if (!gfxDriver->UsesMemoryBackBuffer()) 
    {
        // D3D driver
        Bitmap *scrndump = BitmapHelper::CreateBitmap(scrnwid, scrnhit, final_col_dep);
        gfxDriver->GetCopyOfScreenIntoBitmap(scrndump);

        update_polled_stuff_if_runtime();

        if ((scrnwid != width) || (scrnhit != height))
        {
            newPic = BitmapHelper::CreateBitmap(width, height, final_col_dep);
            newPic->StretchBlt(scrndump,
                RectWH(0, 0, scrndump->GetWidth(), scrndump->GetHeight()),
                RectWH(0, 0, width, height));
            delete scrndump;
        }
        else
        {
            newPic = scrndump;
        }
    }
    else
    {
        // resize the sprite to the requested size
        newPic = BitmapHelper::CreateBitmap(width, height, virtual_screen->GetColorDepth());

        newPic->StretchBlt(virtual_screen,
            RectWH(0, 0, virtual_screen->GetWidth(), virtual_screen->GetHeight()),
            RectWH(0, 0, width, height));
    }

    // replace the bitmap in the sprite set
    add_dynamic_sprite(gotSlot, gfxDriver->ConvertBitmapToSupportedColourDepth(newPic));
    ScriptDynamicSprite *new_spr = new ScriptDynamicSprite(gotSlot);
    GlobalReturnValue.SetDynamicObject(new_spr, new_spr);
    return new_spr;
}
开发者ID:Cheeseness,项目名称:ags,代码行数:54,代码来源:dynamicsprite.cpp

示例3: CreateDynamicSprite

int IAGSEngine::CreateDynamicSprite(int32 coldepth, int32 width, int32 height) {

    int gotSlot = spriteset.findFreeSlot();
    if (gotSlot <= 0)
        return 0;

    if ((width < 1) || (height < 1))
        quit("!IAGSEngine::CreateDynamicSprite: invalid width/height requested by plugin");

    // resize the sprite to the requested size
    Bitmap *newPic = BitmapHelper::CreateTransparentBitmap(width, height, coldepth);
    if (newPic == NULL)
        return 0;

    // add it into the sprite set
    add_dynamic_sprite(gotSlot, newPic);
    return gotSlot;
}
开发者ID:JackSamurai,项目名称:ags,代码行数:18,代码来源:agsplugin.cpp

示例4: DynamicSprite_Create

ScriptDynamicSprite* DynamicSprite_Create(int width, int height, int alphaChannel) 
{
    multiply_up_coordinates(&width, &height);

    int gotSlot = spriteset.findFreeSlot();
    if (gotSlot <= 0)
        return NULL;

    Bitmap *newPic = BitmapHelper::CreateTransparentBitmap(width, height, System_GetColorDepth());
    if (newPic == NULL)
        return NULL;

    if ((alphaChannel) && (System_GetColorDepth() < 32))
        alphaChannel = false;

    add_dynamic_sprite(gotSlot, ReplaceBitmapWithSupportedFormat(newPic), alphaChannel != 0);
    ScriptDynamicSprite *new_spr = new ScriptDynamicSprite(gotSlot);
    return new_spr;
}
开发者ID:AlanDrake,项目名称:ags,代码行数:19,代码来源:dynamicsprite.cpp

示例5: DynamicSprite_CreateFromExistingSprite

ScriptDynamicSprite* DynamicSprite_CreateFromExistingSprite(int slot, int preserveAlphaChannel) {

    int gotSlot = spriteset.findFreeSlot();
    if (gotSlot <= 0)
        return NULL;

    if (!spriteset.doesSpriteExist(slot))
        quitprintf("DynamicSprite.CreateFromExistingSprite: sprite %d does not exist", slot);

    // create a new sprite as a copy of the existing one
    Bitmap *newPic = BitmapHelper::CreateBitmapCopy(spriteset[slot]);
    if (newPic == NULL)
        return NULL;

    bool hasAlpha = (preserveAlphaChannel) && ((game.spriteflags[slot] & SPF_ALPHACHANNEL) != 0);

    // replace the bitmap in the sprite set
    add_dynamic_sprite(gotSlot, newPic, hasAlpha);
    ScriptDynamicSprite *new_spr = new ScriptDynamicSprite(gotSlot);
    return new_spr;
}
开发者ID:AlanDrake,项目名称:ags,代码行数:21,代码来源:dynamicsprite.cpp

示例6: DynamicSprite_Create

ScriptDynamicSprite* DynamicSprite_Create(int width, int height, int alphaChannel) 
{
    multiply_up_coordinates(&width, &height);

    int gotSlot = spriteset.findFreeSlot();
    if (gotSlot <= 0)
        return NULL;

    Bitmap *newPic = BitmapHelper::CreateBitmap(width, height, final_col_dep);
    if (newPic == NULL)
        return NULL;
    newPic->Clear(newPic->GetMaskColor());

    if ((alphaChannel) && (final_col_dep < 32))
        alphaChannel = false;

    add_dynamic_sprite(gotSlot, gfxDriver->ConvertBitmapToSupportedColourDepth(newPic), alphaChannel != 0);
    ScriptDynamicSprite *new_spr = new ScriptDynamicSprite(gotSlot);
    GlobalReturnValue.SetDynamicObject(new_spr, new_spr);
    return new_spr;
}
开发者ID:Cheeseness,项目名称:ags,代码行数:21,代码来源:dynamicsprite.cpp

示例7: DynamicSprite_CreateFromBackground

ScriptDynamicSprite* DynamicSprite_CreateFromBackground(int frame, int x1, int y1, int width, int height) {

    if (frame == SCR_NO_VALUE) {
        frame = play.bg_frame;
    }
    else if ((frame < 0) || (frame >= thisroom.num_bscenes))
        quit("!DynamicSprite.CreateFromBackground: invalid frame specified");

    if (x1 == SCR_NO_VALUE) {
        x1 = 0;
        y1 = 0;
        width = play.room_width;
        height = play.room_height;
    }
    else if ((x1 < 0) || (y1 < 0) || (width < 1) || (height < 1) ||
        (x1 + width > play.room_width) || (y1 + height > play.room_height))
        quit("!DynamicSprite.CreateFromBackground: invalid co-ordinates specified");

    multiply_up_coordinates(&x1, &y1);
    multiply_up_coordinates(&width, &height);

    int gotSlot = spriteset.findFreeSlot();
    if (gotSlot <= 0)
        return NULL;

    // create a new sprite as a copy of the existing one
    Bitmap *newPic = BitmapHelper::CreateBitmap(width, height, thisroom.ebscene[frame]->GetColorDepth());
    if (newPic == NULL)
        return NULL;

    newPic->Blit(thisroom.ebscene[frame], x1, y1, 0, 0, width, height);

    // replace the bitmap in the sprite set
    add_dynamic_sprite(gotSlot, newPic);
    ScriptDynamicSprite *new_spr = new ScriptDynamicSprite(gotSlot);
    GlobalReturnValue.SetDynamicObject(new_spr, new_spr);
    return new_spr;
}
开发者ID:Cheeseness,项目名称:ags,代码行数:38,代码来源:dynamicsprite.cpp

示例8: DynamicSprite_CreateFromExistingSprite

ScriptDynamicSprite* DynamicSprite_CreateFromExistingSprite(int slot, int preserveAlphaChannel) {

    int gotSlot = spriteset.findFreeSlot();
    if (gotSlot <= 0)
        return NULL;

    if (!spriteset.doesSpriteExist(slot))
        quitprintf("DynamicSprite.CreateFromExistingSprite: sprite %d does not exist", slot);

    // create a new sprite as a copy of the existing one
    Bitmap *newPic = BitmapHelper::CreateBitmap(spritewidth[slot], spriteheight[slot], spriteset[slot]->GetColorDepth());
    if (newPic == NULL)
        return NULL;

    newPic->Blit(spriteset[slot], 0, 0, 0, 0, spritewidth[slot], spriteheight[slot]);

    bool hasAlpha = (preserveAlphaChannel) && ((game.spriteflags[slot] & SPF_ALPHACHANNEL) != 0);

    // replace the bitmap in the sprite set
    add_dynamic_sprite(gotSlot, newPic, hasAlpha);
    ScriptDynamicSprite *new_spr = new ScriptDynamicSprite(gotSlot);
    GlobalReturnValue.SetDynamicObject(new_spr, new_spr);
    return new_spr;
}
开发者ID:Cheeseness,项目名称:ags,代码行数:24,代码来源:dynamicsprite.cpp


注:本文中的SpriteCache::findFreeSlot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。