English 中文(简体)
• 如何在Pipe上为射击游戏制造损害屏障?
原标题:How to create a damage bar for a shooting game on iPhone?

I have a question in game development. I am building a game for iPhone. At the game play, there is a damage bar, that displays what the player has damage the enemies. The technique I use is using 2 pictures. One is a damage bar which is fill with full damage, and one is jus a black bar but same size with the damage bar. It is like masking. I will scale the black bar shorter whenever it receives the value of the damage. But the problem here is the method i use to calculate the damage is different class from the method i use to draw the black bar. How do I draw it frequently everytime it gets a damage value? please help me , thank you so much.

-(void)damageTaken
{
    totalDamage = 0;
    for (uint i = 0 ; i< [bodyParts count]; i++) {
        RagdollBodypart *part = (RagdollBodypart *)[bodyParts objectAtIndex:i];
        totalDamage += part.damage;
    }
    [[NSNotificationCenter defaultCenter] postNotificationName:DAMAGE_TAKEN object:nil];
}

以上是计算损害所用的方法。 每当参与者打什么东西时都会被叫到。 它是由一个称为“身体残疾”的班子创建的。

这部法律是用来为损害之 bar取面罩。 这只是一次行动,我怎么能够以与损失相同的数量来处理这个问题?

 float damage = [[GameController instance].engine.enemies totalDamage];
                        float scale = (float)(1400 -damage)/(float)1400;
                        [damageSprMask setScaleY:scale];
                        //[damageSprMask setPosition:ccp(20,150)];
                        [damageSprMask setPosition:ccp(20,150 +((1- damageSprMask.scaleY)*damageSpr.contentSize.height)/2)];
最佳回答

为了让自己重新思考,你可以使用[观点”来看待这一看法。

因此,你可以直接叫作损害 采用或采用倾听你再次发出的通知的方法。

问题回答

感谢ur答。 我现在解决了这一问题。 我所做的工作只是创造了另一个标准职能。 我将说,这种功能与我的框架相类似,是60次。 现在,我的破坏会受到罚款。 但是,我也感谢你,我认为你的工作方式是好的。





相关问题
Asynchronous request to the server from background thread

I ve got the problem when I tried to do asynchronous requests to server from background thread. I ve never got results of those requests. Simple example which shows the problem: @protocol ...

objective-c: Calling a void function from another controller

i have a void, like -(void) doSomething in a specific controller. i can call it in this controller via [self doSomething], but i don t know how to call this void from another .m file. I want to call ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

NSUndoManager and runModalForWindow:

I have a simple Core Data app which displays a list of entities in the main window. To create or add new entities, I use a second modal window with a separate managed object context so changes can be ...

NSMutableArray values becoming "invalid"

I m trying to show a database information in a tableview and then the detailed information in a view my problem is as follow: I created a NSMutableArray: NSMutableArray *myArray = [[NSMutableArray ...

iPhone numberpad with decimal point

I am writing an iPhone application which requires the user to enter several values that may contain a decimal point (currency values, percentages etc.). The number of decimal places in the values ...

热门标签