Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
I'm all new at iOS dev. I have built some simple projects with Cocos2d, just to get up to date - but still having some troubles.
I would really like to see some code that shows me how to build a grid where I can move a blocks/squares around with multitouch within that grid. Movement should be restricted to the grid. So you should not be able to move freely, but only horizontal/vertical whenever your block is aligned with the grid system. Also it would be cool if there is some collision detection so you can't move through another block.
A grid size of 4x4 e.g. 400x400pt where the block/square you move around is 100x100pt.
Here is a example image:
Anybody who have some examples or would like to help out, it doesn't matter if it's not cocos2d.
I wouldn't worry about what's displayed on the screen first - I'd think about what our objects are, what actions they perform, and what data access you need. Then figure out how to write those; then figure out how to display it.
It sounds like you have a Grid and some Blocks. The Grid object needs to store all of the blocks; when it's time to get touch controls working you'll want to ask questions like "what block is in position 1,1" and "what moves are available from 1,1", so the Grid object needs a way to answer that.
A simple way to so that is with a two-dimensional C array of pointers. Each grid square would have a pointer to the block in that square, or nil if there is no block.
//actions -(void)addBlock:(Block*) block; -(bool)moveBlock:(Block*) to:(gridPoint)point //use this to make the move, if it is valid
//data access -(Block*)getBlockAt:(gridPoint) point; find the block at a point when touching -(bool)isValidMove:(gridPoint) forBlock:(Block*)block //use this to find out if the move is valid after a drag or tap @end;
Once you have these building blocks ready then you can create a scene with sprites and have it make calls into this "data model". The rules of the game will be in the data model, not your view/sprite code.
I'm all new at iOS dev. I have built some simple projects with Cocos2d, just to get up to date - but still having some troubles.
I would really like to see some code that shows me how to build a grid where I can move a blocks/squares around with multitouch within that grid. Movement should be restricted to the grid. So you should not be able to move freely, but only horizontal/vertical whenever your block is aligned with the grid system. Also it would be cool if there is some collision detection so you can't move through another block.
A grid size of 4x4 e.g. 400x400pt where the block/square you move around is 100x100pt.
Here is a example image:
Anybody who have some examples or would like to help out, it doesn't matter if it's not cocos2d.
I need to build a Grid. The grid could be any size, 3x3, 9x9 or 4x4 like the image. Then I need to be able to move some Blocks in the grid, and then last check where blocks are positioned. So I think that smashers method is the way to go.
I would like to end up with a grid and some blocks that are moveable via touch and allow two blocks to move simultaneously via multitouch - also the blocks should not be able to move through each other and the movement should be restricted to the grid.
I'm coming from a C# background and all this objective-c is all new to me. I should probably write this is in C# and then convert it.
Replies
It sounds like you have a Grid and some Blocks. The Grid object needs to store all of the blocks; when it's time to get touch controls working you'll want to ask questions like "what block is in position 1,1" and "what moves are available from 1,1", so the Grid object needs a way to answer that.
A simple way to so that is with a two-dimensional C array of pointers. Each grid square would have a pointer to the block in that square, or nil if there is no block.
Once you have these building blocks ready then you can create a scene with sprites and have it make calls into this "data model". The rules of the game will be in the data model, not your view/sprite code.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeIs tilemap what you are looking for?
iPhone SDK Fanatic!
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeIt's actually more like what Smasher says.
I need to build a Grid. The grid could be any size, 3x3, 9x9 or 4x4 like the image. Then I need to be able to move some Blocks in the grid, and then last check where blocks are positioned. So I think that smashers method is the way to go.
I would like to end up with a grid and some blocks that are moveable via touch and allow two blocks to move simultaneously via multitouch - also the blocks should not be able to move through each other and the movement should be restricted to the grid.
I'm coming from a C# background and all this objective-c is all new to me. I should probably write this is in C# and then convert it.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome