Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Beginning iOS Game Development
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning iOS Game Development
This is the forum to discuss the Wrox book Beginning iOS Game Development by Patrick Alessi ; ISBN: 978-1-1181-0732-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning iOS Game Development section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 19th, 2012, 08:22 PM
Authorized User
Points: 70, Level: 1
Points: 70, Level: 1 Points: 70, Level: 1 Points: 70, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Attempting my first game, and hit a major roadblock...

I'm trying to make a space shooter. I'm DESPERATE of help so if anyone can help, let me know. The book doesn't address this issue (but if it does, it's hidden in the "Blocker" chapter, but I've spent hours staring at it and I can't figure it out)

So I have a space ship on the left. It shooting bullets rightward, but the bullet stops moving forward right when the next bullet is fired. So only one bullet moves at a time (and it would be the most recent bullet).

The way I programmed it, I used the screen refresh method to trigger it. On my view controller.m:

-(void) updateDisplay:(CADisplayLink *)sender
{

[fishFrames setFrame:gameModel.fishRect];
[bulletLv1 moveForward];
}

bulletLv1 is an instance of "bulletImageView" which is a subclass of UIImageView. and the "moveForward" method is defined as:

-(void) moveForward
{
self.center = CGPointMake(self.center.x +10, self.center.y);
}


My main issue is I don't know how to have multiple versions of the same object move independently. I'm guessing I might need to use MSMutable Arrays but I don't know. If anyone has any advice thanks...
Reply With Quote
  #2 (permalink)  
Old March 20th, 2012, 02:08 AM
Authorized User
Points: 70, Level: 1
Points: 70, Level: 1 Points: 70, Level: 1 Points: 70, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OMG OMG OMG ! I fixed it!!!

I took a 5 hour break, and it just hit me. I was thinking of NES games, why the characters can shoot only 2 bullets, and I thought "maybe it's a memory allocation issue."

So I copied this critical line from Blocker and bracketed around the code that moved a bullet forward, and it fixed it.

"for (BlockView* bv in blockArray){"

I'm guessing the reason this worked is because originally I relied on one line of code to move all bullets. But it doesn't work like that. ten bullets needs ten actions. And 15 bullets need 15 actions. But by using this like, it "scans" the entire array to count how many bullets, and will perform as many actions as there are bullets.
Reply With Quote
  #3 (permalink)  
Old March 22nd, 2012, 09:56 PM
Authorized User
Points: 50, Level: 1
Points: 50, Level: 1 Points: 50, Level: 1 Points: 50, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Location: Ottawa, On, Canada
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi Gordio, this happens to me more often than I'd care to admit. I spend hours trying to fix something and come back to it at a later time or the next day and solve it in minutes. I'm sure it has something to do with getting a fresh look at the problem but I'm too stubborn sometimes to give up and take a break. ;)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Activities Example Attempting to Connect Debugger rman BOOK: Beginning Android Application Development 0 August 22nd, 2011 09:34 AM
Attempting to Insert Value into DB Query Snuffles ASP.NET 2.0 Basics 2 April 2nd, 2007 08:17 AM
I am a beginner, and i need major help!!! ironchef Java Basics 6 July 28th, 2006 03:45 AM
Error when attempting to add New Topic rudydotnet Classic ASP Databases 1 August 22nd, 2005 01:55 PM
Need Major Help!!!!!!!!!!!!!!!! Phrozen1der JSP Basics 0 May 10th, 2004 04:53 PM



All times are GMT -4. The time now is 09:34 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.