英文:
doesn't load image palette in PAL0 -> VDP_setPalette(PAL0,sprite_sonic.palette->data)
问题
决定研究一下SGDK。我想要将索尼克的精灵添加到屏幕上,但出了些问题。索尼克的精灵加载了,但没有使用他的调色板。在加载时,使用了PAL0调色板,其中默认颜色保持不变(尽管我有点改变了它们)。
这里是一个有问题的照片 -> sonic。
这张照片显示索尼克是黑白的,而PAL0没有改变。
以下是代码:
#include <genesis.h>
#include "sprites.h"
Sprite* my_sprite_sonic;
int main()
{
VDP_setBackgroundColor(40);
VDP_setScreenWidth320();
SPR_init();
VDP_setPalette(PAL0, sprite_sonic.palette->data);
my_sprite_sonic = SPR_addSprite(&sprite_sonic, 0, 0, TILE_ATTR(PAL0, TRUE, FALSE, FALSE));
while(TRUE)
{
SPR_update();
SYS_doVBlankProcess();
}
return 0;
}
如果我做错了什么,提前道歉。我是SGDK的新手。我搜索了这个问题,但找不到答案。
英文:
Decided to look into the SGDK. I wanted to add a Sonic's sprite to the screen, but something went wrong. Sonic's sprite loads but not in his palette. When loading, the PAL0 palette is used, in which the default colors remain (although I kind of changed them).
Here is a photo with a problem -> sonic.
This photo shows that Sonic is Black and White, and that PAL0 has not changed.
Here is the code:
#include <genesis.h>
#include "sprites.h"
Sprite* my_sprite_sonic;
int main()
{
VDP_setBackgroundColor(40);
VDP_setScreenWidth320();
SPR_init();
VDP_setPalette(PAL0,sprite_sonic.palette->data);
my_sprite_sonic = SPR_addSprite(&sprite_sonic, 0, 0, TILE_ATTR(PAL0, TRUE, FALSE, FALSE));
while(TRUE)
{
SPR_update();
SYS_doVBlankProcess();
}
return 0;
}
If I'm being stupid, I apologize in advance. New to SGDK. I googled the question but couldn't find anything.
答案1
得分: 0
VDP_setPalette(PAL0,sprite_sonic.palette->data);
替换为 PAL_setPalette(PAL0, sonic_sprite.palette->data, DMA);
英文:
Instead of
VDP_setPalette(PAL0,sprite_sonic.palette->data);
you need to use
PAL_setPalette(PAL0, sonic_sprite.palette->data, DMA);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论