Super noob Objective C help needed
By : Sruthi
Date : March 29 2020, 07:55 AM
will help you First of all, instead of putting the count as a global variable, it's more appropriate to put it in your interface instead. And regarding the question you have, your code should be changed to something like this. code :
- (IBAction)addUnit {
//if(count >= 999) return; Delete this line, there is absolutely no point for this line this line to exist. Basically, if the count value is above 999, it does nothing.
NSString *numValue;
if (count>=999)
{
//Your other string
}
else
{
numValue = [[NSString alloc] initWithFormat:@"%d", count++];
}
counter.text = numValue;
[numValue release];//Are you using Xcode 4.2 in ARC? If you are you can delete this line
}
|
Designated Initializers for subclasses in obj-c, super noob
By : Prasad C
Date : March 29 2020, 07:55 AM
seems to work fine Yes, that's correct. You can call any of the superclass' initialisers, in fact.
|
What Event should I use (clearly not MouseEvent) [I'm super new to as3]
By : Ramsh
Date : March 29 2020, 07:55 AM
To fix the issue you can do If I'm understanding correctly, you have a bunch of items (only 1 shown in your code to keep it simple? merch.b1?). When any of those items are clicked, you want to make the clover glow if your items var is greater or equal to 1. If I have that right, then this should answer your question (with some tips thrown in to reduce redundant code). code :
//add a click event to the clover
clover.addEventListener(MouseEvent.CLICK, cloverClick);
//disable the ability to click the clover at first
clover.mouseEnalbled = false;
clover.mouseChildren = false;
//click listeners for your items
merch.b1.addEventListener(MouseEvent.CLICK, itemClick);
function itemClick(e:MouseEvent):void {
//make the item disappear
var itemClicked:DisplayObject = e.currentTarget as DisplayObject;
//e.currentTarget is a reference to the item clicked
//so you can have just this one handler for all the items mouse clicks
itemClicked.visible = false;
//if you want the item to be garbage collect (totally gone), you also need to remove it from the display (instead of just making it invisible)
itemClicked.parent.removeChild(itemClicked);
items++
itemClicked.removeEventListener(MouseEvent.CLICK, itemClick);
//now see if the clover needs to grow
playUp();
}
//explain the payUp function
function payUp(){
if (items >= 1) {
//make the clover glow green
TweenMax.to(clover, 0.5, {glowFilter:{color:0x66CC00, alpha:1, blurX:40, blurY:40}});
//make the clover clickable
clover.buttonMode = true;
clover.useHandCursor = true;
clover.mouseEnalbled = true;
clover.mouseChildren = true;
}
}
function cloverClick(e:Event):void {
//do whatever you need to do when the clover is clicked
}
|
Type 'MouseEvent<Element, MouseEvent>' is not assignable to type 'MouseEvent<HTMLDivElement, MouseEvent>'
By : user3732819
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further After checked the document around hereYou may find the hierarchy relationship like: code :
// Before
const handleContextMenu = (...) => (e: React.MouseEvent<HTMLDivElement, MouseEvent>) : void => {
...
}
// After
const handleContextMenu = (...) => (e: React.MouseEvent<Element, MouseEvent>) : void => {
...
}
|
Super Noob C++ variable help
By : craig ma
Date : January 02 2021, 06:48 AM
this one helps. Well you didn't state the problem with the code other than it doesn't work. I'm suspicious of your use of AvgPower() in the for_each. Also, you have AvgPower as a class. why not a double or something? For this code I would have expected to see something like this:
|