Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Simple Tile Array

Author
Message
Steveotronic
9
Years of Service
User Offline
Joined: 8th Feb 2015
Location: Leicestershire
Posted: 8th Feb 2015 02:05
Hi,

I have tried searching the forums but can find nothing that makes any sense to me or anything that works how i expect it should.

I am new to AppGameKit (Obviously) and have been pulling my hair out over a timely array. i just want to know how to do it.

I have the following code which is just like a testing playground. if someone could help me/explain why the tiles are not displaying as they should (in a line), it would be very much appreciated.

Many thanks in advance

Lucas Tiridath
AGK Developer
16
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 8th Feb 2015 09:04
Well I can't run your code without the assets but the problem seems to be here.



You're using the values in Map to determine which image to use, which is fair enough. However you then run this line



which creates a sprite but doesn't save the handle to it. You then attempt to position something that isn't a sprite like so.

SetSpritePosition ( Map[x], x*tile, 0 )

Remember Map contains your enums specifying which image to use, not the Id of the sprite. As a quick fix, you could do something like this.



However in the longer term, you might want to permanently save the sprite handles, perhaps by storing them in another array.

Like I say, I've not been able to run the code, so I don't know exactly what problem you're seeing or whether this fixes it. Anyhow I hope that helps.

Steveotronic
9
Years of Service
User Offline
Joined: 8th Feb 2015
Location: Leicestershire
Posted: 8th Feb 2015 11:31
Lucas,

Oh man, what a donkey I am. Thank you.

I have created the handles for the sprites, and that fixed the problem, I also changed the loop to go from 0 to 9 as i was getting an extra image at the end.

The Map[x] in the setspriteposition was just me trying something out as I couldn't get it to work, but I understand it now. I think i had been at this problem for over an hour and I was trying anything.

Yes I think storing the handles in an array will be good idea for the future.

Thanks so much for your help.

Really appreciated

Steve

Login to post a reply

Server time is: 2024-11-23 08:04:57
Your offset time is: 2024-11-23 08:04:57