#175477 - NaclChan - Tue Nov 30, 2010 5:55 pm
Hello everyone:
I am a newbie NDS programmer from China,recently I am working hard on how to display my animate sprites correctly,but I always get a wrong one.When I want to display my sprite at the left-top(0,0), the sprite shows up near (30,30). The picture below shows what happened.
[img]
http://photo.renren.com/photo/36105/photo-3742550579?curpage=0&t=
[/img]
I checked my code,but I found nothing strange.So I come here to see if I can get some help from you. Sorry to bother you guys.
The code below is how I set the display mode and things like that
Here are the code I used to set my sprite
Now I will show the strcture of my sprite
BTW:I am glad to say hello to everyone,thank you
Last edited by NaclChan on Wed Dec 01, 2010 11:36 am; edited 1 time in total
I am a newbie NDS programmer from China,recently I am working hard on how to display my animate sprites correctly,but I always get a wrong one.When I want to display my sprite at the left-top(0,0), the sprite shows up near (30,30). The picture below shows what happened.
[img]
http://photo.renren.com/photo/36105/photo-3742550579?curpage=0&t=
[/img]
I checked my code,but I found nothing strange.So I come here to see if I can get some help from you. Sorry to bother you guys.
The code below is how I set the display mode and things like that
Code: |
//设置图像引擎的工作模式 videoSetMode(MODE_5_2D); //把精灵的存储空间映射到BankA,根据libnds的说明,只有特定的bank才能映射 vramSetBankA(VRAM_A_MAIN_SPRITE); irqInit(); irqEnable(IRQ_VBLANK); irqSet(IRQ_VBLANK,vBlank); |
Here are the code I used to set my sprite
Code: |
//设置精灵的映射方式为1D映射,现在对这个还不是相当的了解 oamInit(&oamMain, SpriteMapping_1D_128, false); //为精灵的Tile数据申请一个存储的空间,mainSprite.gfx指向新申请的空间的基址 //并设置精灵的显示为256色的tile方式,不是bmp方式 mainSprite.gfx = oamAllocateGfx(&oamMain, SpriteSize_32x32, SpriteColorFormat_256Color); //在控制精灵动作的时候有一个指向实际要显示tile的基址,初始时为整个tile数据的基址 baseGfx = mainSprite.gfx; //将tile数据,调色盘数据载入相应的空间之中 dmaCopyHalfWords(3,test_Char,mainSprite.gfx,sizeof(test_Char)); dmaCopyHalfWords(3,test_Palette,SPRITE_PALETTE,sizeof(test_Palette)); |
Now I will show the strcture of my sprite
Code: |
typedef struct { signed int x; signed int y; int speed; SpriteSize size; SpriteColorFormat format; u16* gfx; }MySprite; //定义一个精灵的结构体,存放精灵的初始信息 MySprite mainSprite = {0,0,10,SpriteSize_32x32,SpriteColorFormat_256Color,0}; |
BTW:I am glad to say hello to everyone,thank you
Last edited by NaclChan on Wed Dec 01, 2010 11:36 am; edited 1 time in total